CzxxPanel = function(){
    
    this.grid = new CzHouseGrid(this, {
    });
    
    var czxxTplMarkup = [
        '<font color="green">【{wymc}】 {khxm}</font><br/>',
        '【电话:】<font color="red">{khdh}</font><br/>',
        '【描述:】{bz}<br/><br/>',
        '{ygbm}: {ygxm} [{create_at:date("Y-m-d")}委托]<br/>'
    ];
    
    var czxxTpl = new Ext.Template(czxxTplMarkup);
    
    /*
    var options = {
      projection: new OpenLayers.Projection('EPSG:900913'), units: "m", maxResolution: 152.87405654296876,
      maxExtent: new OpenLayers.Bounds(-2.003750834E7,-2.003750834E7,2.003750834E7,2.003750834E7) 
    };
    
    
    var map  = new OpenLayers.Map($('map'), options);
    var gsat = new OpenLayers.Layer.Google("gsat", {type: G_SATELLITE_MAP, "sphericalMercator": true,  opacity: 1, numZoomLevels: 20});
    var gmap = new OpenLayers.Layer.Google("gmap", {type: G_NORMAL_MAP, "sphericalMercator": true,   opacity: 1, numZoomLevels: 20});
    map.addLayers([gsat,gmap]);
    //add OpenLayers controls 
    map.addControl(new OpenLayers.Control.LayerSwitcher());
    map.addControl(new OpenLayers.Control.Graticule({numPoints: 2,labelled: true,visible: true}));
    map.setCenter(new OpenLayers.LonLat(13470500, 3683278), 15);
    */    

    var add_contract = function(gsm) {
      var contract_win = new Ext.Window({
          title: '合同信息',
          floating: true,
          shadow: true,
          draggable: true,
          closable: true,
          modal: true,
          width: 750,
          height: 450,
          layout: 'fit',
          plain: true,
          items: [{
            xtype:"form",
            id : 'contract_add_form',
            width: 730,
            height: 450,
            padding: 10,
            layout: 'absolute',
            items:[
                {
                  xtype: 'textfield',
                  name: 'id',
                  hidden: true  
                },
                {
                  xtype: 'textfield',
                  name: 'czxx_id',
                  hidden: true  
                },
                {
                  xtype: 'textfield',
                  name: 'qzxx_id',
                  hidden: true  
                },                
                {
                    xtype: 'label',
                    text: '合同编号：',
                    x: 20,
                    y: 10
                },
                {
                    xtype: 'label',
                    text: '出租编号：',
                    x: 200,
                    y: 10
                },
                {
                    xtype: 'label',
                    text: '求租编号：',
                    x: 380,
                    y: 10
                },
                {
                    xtype: 'label',
                    text: '签约日期：',
                    x: 560,
                    y: 10
                },
                {
                    xtype: 'label',
                    text: '出租方（甲方）',
                    x: 20,
                    y: 50
                },
                {
                    xtype: 'label',
                    text: '求租（乙方）',
                    x: 380,
                    y: 50
                },
                {
                    xtype: 'label',
                    text: '地址：',
                    x: 20,
                    y: 80
                },
                {
                    xtype: 'label',
                    text: '地址：',
                    x: 380,
                    y: 80
                },
                {
                    xtype: 'label',
                    text: '联系人：',
                    x: 20,
                    y: 110
                },
                {
                    xtype: 'label',
                    text: '联系人：',
                    x: 380,
                    y: 110
                },
                {
                    xtype: 'label',
                    text: '电话：',
                    x: 20,
                    y: 140
                },
                {
                    xtype: 'label',
                    text: '电话：',
                    x: 380,
                    y: 140
                },
                {
                    xtype: 'label',
                    text: '面积：',
                    x: 20,
                    y: 180
                },
                {
                    xtype: 'label',
                    text: '年限：',
                    x: 380,
                    y: 180
                },
                {
                    xtype: 'label',
                    text: '租期：',
                    x: 20,
                    y: 210
                },
                {
                    xtype: 'label',
                    text: '首期租金时间：',
                    x: 20,
                    y: 240
                },
                {
                    xtype: 'label',
                    text: '交房时间：',
                    x: 20,
                    y: 270
                },
                {
                    xtype: 'label',
                    text: '定金保证金：',
                    x: 20,
                    y: 300
                },
                {
                    xtype: 'label',
                    text: '客户身份证：',
                    x: 20,
                    y: 330
                },
                {
                    xtype: 'label',
                    text: '备注：',
                    x: 380,
                    y: 240
                },
                {
                    xtype: 'label',
                    text: '签约人：',
                    x: 380,
                    y: 330
                },
                {
                    xtype: 'label',
                    text: '租金/年：',
                    x: 380,
                    y: 210
                },
                {
                    xtype: 'textfield',
                    x: 80,
                    y: 10,
                    width: 100,
                    name: 'hybh'
                },
                {
                    xtype: 'textfield',
                    x: 260,
                    y: 10,
                    width: 100,
                    name: 'czbh',
                    listeners:{
                      scope: this,
                      'blur': function(field){
                        //if (field.getValue() != field.startValue){
                        if (field.getValue().length > 0){
                          var pars = {czbh:field.getValue()};
                          new Ajax.Request("/desktop/check_contrack_czbh", 
                            { method: "POST",
                              parameters: pars,
                              onComplete:  function(request) {
                                var users = eval("("+request.responseText+")");
                                if (users.size() > 0) {

                                  select = users[0].users;
                                  var form = Ext.getCmp('contract_add_form').form;
                                  form.findField('cz_name').setValue(select['gsmc']);
                                  form.findField('cz_lxr').setValue(select['lxr']);
                                  form.findField('cz_mobile').setValue(select['mobile']);
                                  form.findField('cz_address').setValue(select['address']);
                                  
                                } else {
                                  //Not found CZBH
                                  field.startValue='';
                                  field.setValue('');
                                  Ext.Msg.alert("错误","房源编号不存在！");                                 
                                } 
                              }
                            });                                       
                        }
                      }
                    }
                },
                {
                    xtype: 'textfield',
                    x: 440,
                    y: 10,
                    width: 100,
                    name: 'qzbh',
                    listeners:{
                      scope: this,
                      'blur': function(field){
                        //if (field.getValue() != field.startValue){
                        if (field.getValue().length > 0){
                          var pars = {qzbh:field.getValue()};
                          new Ajax.Request("/desktop/check_contrack_qzbh", 
                            { method: "POST",
                              parameters: pars,
                              onComplete:  function(request) {
                                var users = eval("("+request.responseText+")");
                                if (users.size() > 0) {

                                  select = users[0].users;
                                  var form = Ext.getCmp('contract_add_form').form;
                                  form.findField('qzxx_id').setValue(select['id']);
                                  form.findField('qz_name').setValue(select['gsmc']);
                                  form.findField('qz_lxr').setValue(select['lxr']);
                                  form.findField('qz_mobile').setValue(select['mobile']);
                                  form.findField('qz_address').setValue(select['address']);
                                  
                                } else {
                                  //Not found CZBH
                                  field.startValue='';
                                  field.setValue('');
                                  Ext.Msg.alert("错误","客源编号不存在！");                                 
                                } 
                              }
                            });                                       
                        }
                      }
                    }
                },
                {
                    xtype: 'datefield',
                    x: 620,
                    y: 10,
                    width: 100,
                    name: 'qyrq',
                    format: 'Y-m-d'
                },
                {
                    xtype: 'textfield',
                    x: 110,
                    y: 50,
                    width: 250,
                    name: 'cz_name'
                },
                {
                    xtype: 'textfield',
                    x: 470,
                    y: 50,
                    width: 250,
                    name: 'qz_name'
                },
                {
                    xtype: 'textfield',
                    x: 110,
                    y: 80,
                    width: 250,
                    name: 'cz_address'
                },
                {
                    xtype: 'textfield',
                    x: 470,
                    y: 80,
                    width: 250,
                    name: 'qz_address'
                },
                {
                    xtype: 'textfield',
                    x: 110,
                    y: 110,
                    width: 250,
                    name: 'cz_lxr'
                },
                {
                    xtype: 'textfield',
                    x: 470,
                    y: 110,
                    width: 250,
                    name: 'qz_lxr'
                },
                {
                    xtype: 'textfield',
                    x: 110,
                    y: 140,
                    width: 250,
                    name: 'cz_mobile'
                },
                {
                    xtype: 'textfield',
                    x: 470,
                    y: 140,
                    width: 250,
                    name: 'qz_mobile'
                },
                {
                    xtype: 'textfield',
                    x: 110,
                    y: 180,
                    width: 250,
                    name: 'mianj'
                },
                {
                    xtype: 'textfield',
                    x: 470,
                    y: 180,
                    width: 250,
                    name: 'nianx'
                },
                {
                    xtype: 'textfield',
                    x: 110,
                    y: 210,
                    width: 250,
                    name: 'zuqi'
                },
                {
                    xtype: 'textfield',
                    x: 470,
                    y: 210,
                    width: 250,
                    name: 'zuj'
                },
                {
                    xtype: 'datefield',
                    x: 110,
                    y: 240,
                    width: 250,
                    name: 'sqzfsj',
                    format: 'Y-m-d'
                },
                {
                    xtype: 'datefield',
                    x: 110,
                    y: 270,
                    width: 250,
                    name: 'jfsj',
                    format: 'Y-m-d'
                },
                {
                    xtype: 'textfield',
                    x: 110,
                    y: 300,
                    width: 250,
                    name: 'djbzj'
                },
                {
                    xtype: 'textfield',
                    x: 110,
                    y: 330,
                    width: 250,
                    name: 'khsfz'
                },
                {
                    xtype: 'textarea',
                    x: 470,
                    y: 240,
                    width: 160,
                    name: 'bz',
                    anchor: '100%',
                    height: 80
                },
                {
                    xtype: 'textfield',
                    x: 470,
                    y: 330,
                    width: 160,
                    name: 'qyr',
                    anchor: '100%'
                }
            ],
            buttons:[
              {
                text: '保存',
                handler: function(){
                  var pars = Ext.getCmp("contract_add_form").getForm().getValues();
                  pars['czxx_id']=czxx_id;
                  data['qyr'] = currentUser['login'];
                  pars['yg_id']=currentUser.id; 
                  new Ajax.Request("/desktop/add_contract", { 
                    method: "POST",
                    parameters: pars,
                    onComplete:  function(request) {
                      var users = eval("("+request.responseText+")");
                      if (users.size() > 0) {
                        Ext.getCmp("contract_add_form").getForm().setValues(users[0].users);
                        //contract_win.close(); 
                      } 
                    }
                  });
                }
              },
              {
                text: '关闭',
                handler: function(){
                  contract_win.close(); 
                }
              }]
          }]
      });
      
      if (gsm != undefined) {
        
        var data = gsm.getSelected();
        var contract_id;

        if (data.data.contract_id != undefined) {
          contract_id=data.data.contract_id;
          var pars={contract_id:contract_id};
          new Ajax.Request("/desktop/getContractById", { 
              method: "POST",
              parameters: pars,
              onComplete:  function(request) {
                  var users = eval("("+request.responseText+")");
                  if (users.size() > 0) {
                    var data = users[0].users;
                    Ext.getCmp("contract_add_form").getForm().setValues(data);
                    contract_win.setTitle('合同 - '+data.data.wymc); 
                    contract_win.setIconClass('new');
                  }
              }
          });         
        } else {
          //contract undefined 
          
          var data = {};
          data['qyr'] = currentUser['login'];
          data['qyrq'] = (new Date()).format('Y-m-d');
          data['czbh'] = gsm.getSelected().data.czbh;
          var form = Ext.getCmp("contract_add_form").getForm();
          form.setValues(data);

          contract_win.setTitle('新增合同');
          contract_win.setIconClass('add2');
          
          
        }  
      };
      
      contract_win.show(); 
      contract_win.setZIndex(9020);
    }
    
    var search_lxr = function() {
      var search_win = new Ext.Window({
        title: '查找客户',
        floating: true,
        shadow: true,
        draggable: true,
        closable: true,
        modal: true,
        width: 500,
        height: 300,
        layout: 'fit',
        plain: true,
        tbar: {
            xtype: 'toolbar',
            items: [
                {
                    id : 'search_lxr_query',
                    xtype: 'textfield',
                    width: 298,
                    name: 'query',
                    enableKeyEvents: true, 
                    initEvents: function() { 
                      var keyPress = function(e){ 
                        if (e.getKey() == e.ENTER) { 
                          var search_str = Ext.getCmp('search_lxr_query').getValue();
                          khxx_store.baseParams={filter:search_str};
                          khxx_store.load();
                        }
                      }; 
                      this.el.on("keypress", keyPress, this);
                    }
                },
                {
                    xtype: 'button',
                    text: '查询',
                    tooltip:'智能查询',
                    iconCls:'search',
                    handler : function() {
                      var search_str = Ext.getCmp('search_lxr_query').getValue();
                      khxx_store.baseParams={filter:search_str};
                      khxx_store.load();
                    }
                },
                {
                    xtype: 'button',
                    text: '新增',
                    tooltip:'增加客户',
                    iconCls:'add2',
                    handler:function() {
                       add_lxr('出租');
                    }
                },
                {
                    xtype: 'button',
                    text: '删除',
                    tooltip:'删除客户',
                    iconCls:'delete',
                    handler:function() {
                      var gsm = Ext.getCmp('select_lxr_grid').getSelectionModel();
                      delete_lxr(gsm); 
                    }
                }
            ]
        },
        items:[
            {
                xtype: 'grid',
                height: 243,
                id : 'select_lxr_grid',
                store : khxx_store,
                sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
                columns: [
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'khxm',
                        header: '姓名',
                        sortable: true,
                        width: 100
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'khdh',
                        header: '电话',
                        sortable: true,
                        width: 100
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'khsfz',
                        header: '身份证',
                        sortable: true,
                        width: 150
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'khgj',
                        header: '国籍',
                        sortable: true,
                        width: 100
                    }
                ]
            }
        ]
      });
      
      Ext.getCmp('select_lxr_grid').addListener('rowdblclick',function(t,r,e){
        var select = t.getSelectionModel().getSelections()[0].data;
        var cz_form = Ext.getCmp('czxx_add_form').form;
        cz_form.findField('kh_id').setValue(select['id']);
        cz_form.findField('khxm').setValue(select['khxm']);
        cz_form.findField('khlxr').setValue(select['khlxr']);
        cz_form.findField('khsfz').setValue(select['khsfz']);
        cz_form.findField('khdh').setValue(select['khdh']);
        cz_form.findField('khgj').setValue(select['khgj']);
        
        search_win.close();
      });
      
      khxx_store.load();
      search_win.show();
    };

    var wyzd_store = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '/desktop/get_wyzd'
        }),

        reader: new Ext.data.JsonReader({
          totalProperty: 'results', 
          root: 'rows',             
          fields: [
            {name: 'id'},
            {name: 'wybh',  type: 'string'},
            {name: 'wymc',  type: 'string'},
            {name: 'qy',  type: 'string'},
            {name: 'ygxm',  type: 'string'},
          ]    
        }),
        sortInfo:{field: 'id', direction: "ASC"}
    });

    var add_wyzd = function(gsm) {

/*      
      var  wydd_store = new Ext.data.Store({
        
          proxy: new Ext.data.HttpProxy({
              url: '/desktop/get_wydd'
          }),

          reader: new Ext.data.JsonReader({
            totalProperty: 'results', 
            root: 'rows',             
            fields: [
              {name: 'id'},
              {name: 'dh',  type: 'string'},
              {name: 'cs',  type: 'string'},
              {name: 'cfmj',  type: 'string'},
              {name: 'ssmj',  type: 'string'},
              {name: 'bgmj',  type: 'string'},
              {name: 'kdmj',  type: 'string'},
              {name: 'cc',  type: 'string'},
              {name: 'kk',  type: 'string'},
              {name: 'gg',  type: 'string'},
              {name: 'hc',  type: 'boolean'},
              {name: 'ht',  type: 'boolean'},
              {name: 'bz',  type: 'string'},
              {name: 'published', type:'boolean'}
            ]    
          }),
          baseParams : {wyzd_id:0},
          pruneModifiedRecords:true,
          sortInfo:{field: 'id', direction: "ASC"}
      });
      
      var MyRecord = Ext.data.Record.create([
          {name: 'id', type: 'string'},
          {name: 'dh', type: 'integer'},
          {name: 'cs', type: 'integer'},
          {name: 'cfmj', type: 'integer'},
          {name: 'ssmj', type: 'integer'},
          {name: 'bgmj', type: 'integer'},
          {name: 'kdmj', type: 'integer'},
          {name: 'cc', type: 'integer'},
          {name: 'kk', type: 'integer'},
          {name: 'gg', type: 'integer'},
          {name: 'hc', type: 'boolean'},
          {name: 'ht', type: 'boolean'},
          {name: 'bz', type: 'string'},
          {name: 'published', type: 'boolean'}
      ]);
*/      
      var track_win = new Ext.Window({
          title: '物业字典',
          floating: true,
          shadow: true,
          draggable: true,
          closable: true,
          modal: true,
          width: 518,
          height: 420,
          layout: 'fit',
          plain: true,
          items: [{
            xtype:"form",
            id : 'wyzd_add_form',
            width: 518,
            height: 420,
            padding: 10,
            layout: 'absolute',
            items:[{
                xtype: 'tabpanel',
                activeTab: 0,
                width: 500,
                height: 350,
                deferredRender: false,
                items: [
                    {
                        xtype: 'panel',
                        title: '物业信息',
                        layout: 'absolute',
                        width: 536,
                        height: 409,
                        items: [
                            {
                              xtype: 'textfield',
                              name: 'id',
                              hidden: true  
                            },
                            {
                                xtype: 'label',
                                text: '物业编号',
                                x: 20,
                                y: 10
                            },
                            {
                                xtype: 'label',
                                text: '物业名称',
                                x: 20,
                                y: 40
                            },
                            {
                                xtype: 'label',
                                text: '所在地区',
                                x: 20,
                                y: 70
                            },
                            {
                                xtype: 'label',
                                text: '道路门牌',
                                x: 20,
                                y: 100
                            },
                            {
                                xtype: 'label',
                                text: '业主名称',
                                x: 260,
                                y: 10
                            },
                            {
                                xtype: 'label',
                                text: '土地面积',
                                x: 20,
                                y: 130
                            },
                            {
                                xtype: 'label',
                                text: '土地性质',
                                x: 20,
                                y: 160
                            },
                            {
                                xtype: 'label',
                                text: '土地年限',
                                x: 20,
                                y: 190
                            },
                            {
                                xtype: 'label',
                                text: '土地证号',
                                x: 20,
                                y: 220
                            },
                            {
                                xtype: 'label',
                                text: '房产证号',
                                x: 20,
                                y: 250
                            },
                            {
                                xtype: 'label',
                                text: '道路宽度',
                                x: 260,
                                y: 40
                            },
                            {
                                xtype: 'label',
                                text: '消防等级',
                                x: 260,
                                y: 70
                            },
                            {
                                xtype: 'label',
                                text: '适用行业',
                                x: 260,
                                y: 100
                            },
                            {
                                xtype: 'label',
                                text: '大门朝向',
                                x: 260,
                                y: 130
                            },
                            {
                                xtype: 'label',
                                text: '大门宽度',
                                x: 260,
                                y: 160
                            },
                            {
                                xtype: 'label',
                                text: '大门深度',
                                x: 260,
                                y: 190
                            },
                            {
                                xtype: 'label',
                                text: '登记日期',
                                x: 260,
                                y: 220
                            },
                            {
                                xtype: 'label',
                                text: '登记人',
                                x: 260,
                                y: 250
                            },
                            {
                                xtype: 'textfield',
                                x: 80,
                                y: 10,
                                width: 150,
                                name: 'wybh'
                            },
                            {
                                xtype: 'textfield',
                                x: 80,
                                y: 40,
                                width: 150,
                                name: 'wymc'
                            },
                            {
                                xtype: 'combo',
                                x: 80,
                                y: 70,
                                width: 150,
                                name: 'qy',
                                store: qy_store,
                                emptyText:'请选择',
                                mode: 'remote',
                                minChars : 2,
                                valueField:'value',
                                displayField:'value',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'textfield',
                                x: 80,
                                y: 100,
                                width: 150,
                                name: 'dlmp'
                            },
                            {
                                xtype: 'textfield',
                                x: 80,
                                y: 130,
                                width: 150,
                                name: 'tdmj',
                                emptyText : '0'
                            },
                            {
                                xtype: 'textfield',
                                x: 80,
                                y: 160,
                                width: 150,
                                name: 'tdxz'
                            },
                            {
                                xtype: 'textfield',
                                x: 80,
                                y: 190,
                                width: 150,
                                name: 'tdnx',
                                emptyText : '40'
                            },
                            {
                                xtype: 'textfield',
                                x: 80,
                                y: 220,
                                width: 150,
                                name: 'tdzh'
                            },
                            {
                                xtype: 'textfield',
                                x: 80,
                                y: 250,
                                width: 150,
                                name: 'fczh'
                            },
                            {
                                xtype: 'textfield',
                                x: 320,
                                y: 10,
                                width: 150,
                                name: 'yzmc'
                            },
                            {
                                xtype: 'textfield',
                                x: 320,
                                y: 40,
                                width: 150,
                                name: 'dlkd',
                                emptyText : '0'
                            },
                            {
                                xtype: 'combo',
                                x: 320,
                                y: 70,
                                width: 150,
                                name: 'xfdj',
                                store: xfdj_store,
                                emptyText:'请选择',
                                mode: 'remote',
                                minChars : 2,
                                valueField:'value',
                                displayField:'value',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'textfield',
                                x: 320,
                                y: 100,
                                width: 150,
                                name: 'syhy'
                            },
                            {
                                xtype: 'textfield',
                                x: 320,
                                y: 130,
                                width: 150,
                                name: 'dmcx',
                                emptyText: '南'
                            },
                            {
                                xtype: 'textfield',
                                x: 320,
                                y: 160,
                                width: 150,
                                name: 'dmkd',
                                emptyText : '0'
                            },
                            {
                                xtype: 'textfield',
                                x: 320,
                                y: 190,
                                width: 150,
                                name: 'dmsd',
                                emptyText : '0'
                                
                            },
                            {
                                xtype: 'datefield',
                                x: 320,
                                y: 220,
                                width: 150,
                                format: 'Y-m-d',
                                name: 'create_at',
                                value: (new Date()).format('Y-m-d')
                            },
                            {
                                xtype: 'textfield',
                                x: 320,
                                y: 250,
                                width: 150,
                                name: 'ygxm'
                            }
                        ]
                    },
                    {
                        xtype: 'panel',
                        title: '面积配电',
                        layout: 'absolute',
                        items: [
                            {
                                xtype: 'label',
                                text: '开发面积',
                                x: 20,
                                y: 10
                            },
                            {
                                xtype: 'label',
                                text: '剩余面积',
                                x: 20,
                                y: 40
                            },
                            {
                                xtype: 'label',
                                text: '门卫房面积',
                                x: 20,
                                y: 70
                            },
                            {
                                xtype: 'label',
                                text: '配电房面积',
                                x: 20,
                                y: 100
                            },
                            {
                                xtype: 'label',
                                text: '配电总量',
                                x: 20,
                                y: 130
                            },
                            {
                                xtype: 'label',
                                text: '可用配电总量',
                                x: 20,
                                y: 160
                            },
                            {
                                xtype: 'label',
                                text: '自带发电量',
                                x: 20,
                                y: 190
                            },
                            {
                                xtype: 'label',
                                text: '厂房模式',
                                x: 20,
                                y: 220
                            },
                            {
                                xtype: 'label',
                                text: '总栋数',
                                x: 20,
                                y: 250
                            },
                            {
                                xtype: 'label',
                                text: '信息来源',
                                x: 260,
                                y: 10
                            },
                            {
                                xtype: 'label',
                                text: '备注',
                                x: 260,
                                y: 40
                            },
                            {
                                xtype: 'textfield',
                                x: 90,
                                y: 10,
                                width: 150,
                                name: 'kfmj',
                                emptyText : '0'
                            },
                            {
                                xtype: 'textfield',
                                x: 90,
                                y: 40,
                                width: 150,
                                name: 'symj',
                                emptyText : '0'
                            },
                            {
                                xtype: 'textfield',
                                x: 90,
                                y: 70,
                                width: 150,
                                name: 'mwfmj',
                                emptyText : '0'
                            },
                            {
                                xtype: 'textfield',
                                x: 90,
                                y: 100,
                                width: 150,
                                name: 'pdfmj',
                                emptyText : '0'
                            },
                            {
                                xtype: 'textfield',
                                x: 90,
                                y: 130,
                                width: 150,
                                name: 'pdzl',
                                emptyText : '0'
                            },
                            {
                                xtype: 'textfield',
                                x: 90,
                                y: 160,
                                width: 150,
                                name: 'kypdzl',
                                emptyText : '0'
                            },
                            {
                                xtype: 'textfield',
                                x: 90,
                                y: 190,
                                width: 150,
                                name: 'zdfdl',
                                emptyText : '0'
                            },
                            {
                                xtype: 'combo',
                                x: 90,
                                y: 220,
                                width: 150,
                                name: 'cfms',
                                store: cfms_store,
                                emptyText:'请选择',
                                value:'标准厂房',
                                mode: 'remote',
                                minChars : 2,
                                valueField:'value',
                                displayField:'value',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'textfield',
                                x: 90,
                                y: 250,
                                width: 150,
                                name: 'zds',
                                emptyText : '0'
                            },
                            {
                                xtype: 'combo',
                                x: 330,
                                y: 10,
                                width: 150,
                                name: 'xxly',
                                store: xxly_store,
                                emptyText:'请选择',
                                mode: 'remote',
                                minChars : 2,
                                valueField:'value',
                                displayField:'value',
                                triggerAction:'all',
                                value:'员工采集'
                            },
                            {
                                xtype: 'textarea',
                                x: 260,
                                y: 70,
                                height: 120,
                                width: 220,
                                name: 'bz'
                            }
                        ]
                    },
                    /*
                    {
                      xtype: 'panel',
                      title: '地理位置',
                      layout: 'absolute',
                      items:[
                      {
                          xtype: 'panel',
                          x: 10,
                          y: 10,
                          height: 300,
                          width: 480,
                          items:[{
                              id: "map-route-item",
                              xtype:"panel",
                              height:300,
                              width:480,
                              layout:"absolute",
                              border: false,
                              items:[{
                                id : 'map_route_view',
                                xtype:"panel",
                                height:300,
                                width:480,
                                style:'margin:0px 0px',
                                layout:'fit',
                                border: false,
                                items: [{
                                    xtype: 'mapcomponent',
                                    layout:'fit'
                                    //map: map
                                }]
                              }]
                          }],                     
                        }
                      ]                     
                    },
                    */
                    {
                      xtype: 'panel',
                      title: '栋座图片',
                      layout: 'absolute',
                      id : 'hs-slide-panel',
                      items:[
                      {
                          xtype: 'panel',
                          autoScroll: true,
                          x: 10,
                          y: 40,
                          height: 270,
                          width: 480,
                          html: ''
                      },
                      {
                          xtype: 'button',
                          text: '添加',
                          x: 10,
                          y: 10,
                          width: 35,
                          height: 15,
                          handler : function() {
                            var form = new Ext.form.FormPanel({
                              baseCls: 'x-plain',
                              //layout: 'fit',
                              labelWidth: 80,
                              url:'/desktop/upload',
                              fileUpload:true,
                              defaultType: 'textfield',

                              items: [{
                                  xtype: 'textfield',
                                  hidden: true,
                                  name: 'pars'
                                },{
                                  xtype: 'textfield',
                                  fieldLabel: '文件名',
                                  name: 'userfile',
                                  inputType: 'file',
                                  allowBlank: false,
                                  blankText: '文件名不能为空！',
                                  width: 200
                                },{
                                  xytpe: 'textfield',
                                  fieldLabel:'描述',
                                  width: 240,
                                  name: 'bz',
                                }
                              ]
                            });

                            var win = new Ext.Window({
                              title: '上传文件',
                              width: 400,
                              height:200,
                              minWidth: 300,
                              minHeight: 100,
                              layout: 'fit',
                              plain:true,
                              bodyStyle:'padding:5px;',
                              buttonAlign:'center',
                              items: form,

                              buttons: [{
                                text: '上传',
                                handler: function() {
                                  if(form.form.isValid()){
                                    Ext.MessageBox.show({
                                       title: '请等待。。。',
                                       msg: '传送文件...',
                                       progressText: 'Uploading...',
                                       width:300,
                                       progress:true,
                                       closable:false
                                       //animEl: 'mb6'
                                   });
                                   // this hideous block creates the bogus progress
                                    var f = function(v){
                                        return function(){
                                            if(v == 10){
                                                Ext.MessageBox.hide();
                                            }else{
                                                var i = v/9;
                                                Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
                                            }
                                       };
                                    };
                            
                                    for(var i = 1; i < 11; i++){
                                      setTimeout(f(i), i*500);
                                    }
                                    
                                    var new_form = Ext.getCmp('wyzd_add_form').form;
                                    var wyzd_id = new_form.findField('id').getValue();
                                    
                                    if (wyzd_id=='') {
                                      Ext.Msg.alert('Message','请先保存物业字典后再增加图片.');
                                      win.hide();
                                    } else {
                                      form.getForm().findField('pars').setValue(wyzd_id);
                                      form.getForm().submit({    
                                        success: function(form, action){
                                          Ext.Msg.alert('Message',action.result.msg);
                                          new Ajax.Request("/desktop/get_wyzd_photos", { 
                                              method: "POST",
                                              parameters: pars,
                                              onComplete:  function(request) {
                                                Ext.getDom('my-gallery').innerHTML=request.responseText;
                                              }
                                          });
                                        },    
                                        failure: function(){     
                                          Ext.Msg.alert('Error', 'File upload failure.');    
                                        }
                                      })      
                                    }    
                                  }
                                 }
                              },{
                                text: '关闭',
                                handler:function(){win.hide();}
                              }]
                            });
                            win.show();
                          }
                          
                      },
                      {
                          xtype: 'button',
                          text: '导出图片',
                          x: 60,
                          y: 10,
                          width: 35,
                          height: 15,
                          handler:function(){
                            new Ajax.Request("/desktop/get_wyzd_photos", { 
                                method: "POST",
                                parameters: pars,
                                onComplete:  function(request) {
                                  Ext.getDom('my-gallery').innerHTML=request.responseText;
                                }
                            }); 
                          }
                      }                     
                      ]                     
                    }
                ]
            }],
            buttons:[
              {
                text: '保存',
                handler: function(){
                  var pars = Ext.getCmp("wyzd_add_form").getForm().getValues();
                  pars['czxx_id']=czxx_id;
                  pars['yg_id']=currentUser.id; 
                  new Ajax.Request("/desktop/add_wyzd", { 
                    method: "POST",
                    parameters: pars,
                    onComplete:  function(request) {
                      //var users = eval("("+request.responseText+")");
                      //if (users.size() > 0) {
                      //  Ext.getCmp("wyzd_add_form").getForm().setValues(users[0].users);
                      //} 
                      if (request.responseText.length > 20) { 
                        Ext.Msg.alert('Message','保存物业字典失败. 请与管理员联系后再试！');
                      } else  {
                        Ext.getCmp("wyzd_add_form").getForm().findField('wybh').setValue(request.responseText);
                      }
                    }
                  });
                }
              },
              {
                text: '关闭',
                handler: function(){
                  
                  pars = { wybh:Ext.getCmp("wyzd_add_form").getForm().findField('wybh').getValue()};
                  new Ajax.Request("/desktop/get_wyzd_by_wybh", { 
                    method: "POST",
                    parameters: pars,
                    onComplete:  function(request) {
                      var users = eval("("+request.responseText+")");
                      if (users.size() > 0) {
                        Ext.getCmp("wyzd_add_form").getForm().setValues(users[0].users);
                        var data = Ext.getCmp("wyzd_add_form").getForm().getValues();
                        var cz_form = Ext.getCmp('czxx_add_form').form;
                        cz_form.findField('wyzd_id').setValue(data['id']);

                        cz_form.findField('cq').setValue(data['qy']);
                        cz_form.findField('wymc').setValue(data['wymc']);
                        cz_form.findField('dzwz').setValue(data['dlmp']);
                        cz_form.findField('mpdh').setValue(data['mpdh']);
                        cz_form.findField('zmj').setValue(data['kfmj']);
                        cz_form.findField('dgl').setValue(data['pdzl']);
                        cz_form.findField('fwly').setValue(data['xxly']);

                        track_win.close();                        
                      } 
                    }
                  });
                }
              }]
          }]
      });
      
      Ext.getCmp('hs-slide-panel').items.items[0].html='<div id="my-gallery" class="highslide-gallery"></div>';
      
      if (gsm != undefined) {
        
        var data = gsm.getSelected();
        var wyzd_id;

        if (data.data.wyzd_id != undefined) 
            wyzd_id=data.data.wyzd_id;
        else
            wyzd_id=data.data.id;

        var pars={wyzd_id:wyzd_id};
        new Ajax.Request("/desktop/get_wyzd_by_id", { 
            method: "POST",
            parameters: pars,
            onComplete:  function(request) {
                var users = eval("("+request.responseText+")");
                if (users.size() > 0) {
                  
                  var data = users[0].users;
                  Ext.getCmp("wyzd_add_form").getForm().setValues(data);
                  
                  //set photos
                  new Ajax.Request("/desktop/get_wyzd_photos", { 
                      method: "POST",
                      parameters: pars,
                      onComplete:  function(request) {
                        Ext.getDom('my-gallery').innerHTML=request.responseText;
                      }
                  });
                  
                }
            }
        });
        
        //wydd_store.baseParams={wyzd_id:wyzd_id};
        //wydd_store.reload();
        
        track_win.setTitle('物业字典 - '+data.data.wymc); 
        track_win.setIconClass('new');
      }
      else  {
        var wyzd_id = Ext.getCmp('czxx_add_form').form.findField('wyzd_id').getValue();
        if (wyzd_id=='') {
          var data = {};
          data['ygxm'] = currentUser['login'];
          
          var form = Ext.getCmp("wyzd_add_form").getForm();
          form.setValues(data);
          
          track_win.setTitle('新增物业字典');
          track_win.setIconClass('add2');
        } 
        else {  //非空，刚刚保存过
          var pars={wyzd_id:wyzd_id};
          new Ajax.Request("/desktop/get_wyzd_by_id", { 
              method: "POST",
              parameters: pars,
              onComplete:  function(request) {
                  var users = eval("("+request.responseText+")");
                  if (users.size() > 0) {
                    var data = users[0].users;
                    Ext.getCmp("wyzd_add_form").getForm().setValues(data);

                    track_win.setTitle('物业字典 - '+data.wymc); 
                    track_win.setIconClass('new');

                    //set photos
                    new Ajax.Request("/desktop/get_wyzd_photos", { 
                        method: "POST",
                        parameters: pars,
                        onComplete:  function(request) {
                          Ext.getDom('my-gallery').innerHTML=request.responseText;
                        }
                    });
                    
                  }
              }
          });
        }
      };
      

      //Ext.getCmp('hs-slide-panel').items.items[0].html='<iframe src="http://api.51ditu.com/iframe/newmapwindow.html?city=beijing&lng=11629886&lat=4004734&zoom=2&name=北京灵图软件技术有限公司" height="300" width="400" SCROLLING="no"></iframe>';
      
      track_win.show(); 
      track_win.setZIndex(9020);      
    };
    
    var add_czxx = function(gsm) {
      
      if (gsm != undefined) {
        
        if (currentUser.prev_code[12] != 't') {
            //Ext.Msg.alert('Message','权限不够. 请与管理员联系后再试！');
            //return;
        }
      } else {
        if (currentUser.prev_code[10] != 't') {
            Ext.Msg.alert('Message','权限不够. 请与管理员联系后再试！');
            return;
        }
      }
      
      bm_store.load();
      var test_win = new Ext.Window({
          title: '增加房源',
          floating: true,
          shadow: true,
          draggable: true,
          closable: true,
          modal: true,
          width: 720,
          height: 513,
          layout: 'fit',
          plain: true,
          items: [{
                xtype: 'form',
                width: 668,
                height: 513,
                layout: 'absolute',
                id : 'czxx_add_form',
                defaults: {      // defaults applied to items
                    layout: 'absolute'
                    //border: false,
                    //bodyStyle: 'padding:5px'
                    //y: -10
                },
                items: [
                    {
                        xtype: 'fieldset',
                        layout: 'absolute',
                        width: 710,
                        height: 124,
                        y: 0,
                        padding: 0,
                        items: [
                        {
                                xtype: 'combo',
                                width: 80,
                                fieldLabel: 'Label',
                                name: 'cq',
                                x: 40,
                                y: 20,
                                store: qy_store,
                                emptyText:'请选择',
                                mode: 'remote',
                                minChars : 2,
                                valueField:'value',
                                displayField:'value',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'combo',
                                hidden: true,
                                width: 80,
                                fieldLabel: 'Label',
                                name: 'pq',
                                x: 120,
                                y: 20
                               // store: pq_store,
                               // emptyText:'请选择',
                               // mode: 'local',
                               // valueField:'text',
                               // displayField:'text',
                               // triggerAction:'all'
                            },
                            {
                                xtype: 'textfield',
                                width: 100,
                                name: 'wymc',
                                x: 120,
                                y: 20
                            },
                            {
                                xtype: 'textfield',
                                width: 240,
                                name: 'dzwz',
                                x: 220,
                                y: 20
                            },
                            {
                                xtype: 'textfield',
                                width: 80,
                                name: 'mpdh',
                                x: 460,
                                y: 20
                            },
                            {
                                xtype: 'textfield',
                                width: 70,
                                name: 'lc',
                                x: 540,
                                y: 20
                            },
                            {
                                xtype: 'textfield',
                                width: 70,
                                name: 'zc',
                                x: 610,
                                y: 20
                            },
                            {
                                xtype: 'label',
                                text: '地址',
                                x: 10,
                                y: 20
                            },
                            {
                                xtype: 'label',
                                text: '城区',
                                x: 60,
                                y: 0,
                                style: 'color:gray'
                            },
                            {
                                xtype: 'label',
                                text: '厂房名称',
                                x: 140,
                                y: 0,
                                style: 'color:gray'
                            },
                          //  {
                          //      xtype: 'label',
                          //      text: '厂房名称',
                          //      x: 230,
                          //      y: 0,
                          //      style: 'color:gray'
                          //  },
                            {
                                xtype: 'button',
                                text: '字典',
                                x: 190,
                                y: 0,
                                handler: function(){
                                  if (Ext.getCmp('czxx_add_form').form.findField('id').getValue()=="") {
                                    //search_wyzd();
                                    add_wyzd();
                                  } else {
                                    var gsm = Ext.getCmp('cz-house-grid').getSelectionModel();
                                    add_wyzd(gsm);
                                  }
                                }
                            },
                            {
                                xtype: 'label',
                                text: '地理位置',
                                x: 230,
                                y: 0,
                                style: 'color:gray'
                            },
                            {
                                xtype: 'label',
                                text: '栋数',
                                x: 480,
                                y: 0,
                                style: 'color:gray'
                            },
                            {
                                xtype: 'label',
                                text: '楼层',
                                x: 550,
                                y: 0,
                                style: 'color:gray'
                            },
                            {
                                xtype: 'label',
                                text: '总层',
                                x: 620,
                                y: 0,
                                style: 'color:gray'
                            },
                            {
                                xtype: 'label',
                                text: '厂房',
                                x: 10,
                                y: 50
                            },
                            {
                                xtype: 'label',
                                text: '宿舍',
                                x: 105,
                                y: 50
                            },
                            {
                                xtype: 'label',
                                text: '长',
                                x: 195,
                                y: 50
                            },
                            {
                                xtype: 'label',
                                text: '宽',
                                x: 255,
                                y: 50
                            },
                            {
                                xtype: 'label',
                                text: '高',
                                x: 315,
                                y: 50
                            },
                            {
                                xtype: 'label',
                                text: '用途',
                                x: 375,
                                y: 50
                            },
                            {
                                xtype: 'label',
                                text: '房源编号',
                                x: 485,
                                y: 50
                            },
                            {
                                xtype: 'label',
                                text: '办公',
                                x: 10,
                                y: 80
                            },
                            {
                                xtype: 'label',
                                text: '空地',
                                x: 105,
                                y: 80
                            },
                            {
                                xtype: 'label',
                                text: '总计',
                                x: 195,
                                y: 80
                            },
                            {
                                xtype: 'label',
                                text: '层数',
                                x: 285,
                                y: 80
                            },
                            {
                                xtype: 'label',
                                text: '类型',
                                x: 375,
                                y: 80
                            },
                            {
                                xtype: 'label',
                                text: '建房年代',
                                x: 485,
                                y: 80
                            },
                            {
                                xtype: 'textfield',
                                x: 40,
                                y: 50,
                                width: 60,
                                name: 'cfmj'
                            },
                            {
                                xtype: 'textfield',
                                x: 130,
                                y: 50,
                                width: 60,
                                name: 'ssmj'
                            },
                            {
                                xtype: 'textfield',
                                x: 210,
                                y: 50,
                                width: 40,
                                name: 'length'
                            },
                            {
                                xtype: 'textfield',
                                x: 270,
                                y: 50,
                                width: 40,
                                name: 'width'
                            },
                            {
                                xtype: 'textfield',
                                x: 330,
                                y: 50,
                                width: 40,
                                name: 'height'
                            },
                            {
                                xtype: 'combo',
                                x: 400,
                                y: 50,
                                width: 80,
                                name: 'yt',
                                store: yt_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all', 
                                value: '厂房'
                            },
                            {
                                xtype: 'textfield',
                                x: 540,
                                y: 50,
                                width: 80,
                                //disabled: true,
                                name: 'czbh'
                            },
                            {
                                xtype: 'checkbox',
                                x: 630,
                                y: 40,
                                boxLabel: '优质房',
                                name: 'yzf'
                            },
                            {
                                xtype: 'checkbox',
                                x: 630,
                                y: 60,
                                boxLabel: '网络房',
                                name: 'wlf'
                            },
                            {
                                xtype: 'textfield',
                                x: 40,
                                y: 80,
                                width: 60,
                                name: 'bgmj'
                            },
                            {
                                xtype: 'textfield',
                                x: 130,
                                y: 80,
                                width: 60,
                                name: 'kdmj'
                            },
                            {
                                xtype: 'textfield',
                                x: 220,
                                y: 80,
                                width: 60,
                                name: 'zmj'
                            },
                            {
                                xtype: 'textfield',
                                x: 310,
                                y: 80,
                                width: 60,
                                name: 'cs'
                            },
                            {
                                xtype: 'combo',
                                x: 400,
                                y: 80,
                                width: 80,
                                name: 'lx',
                                store: lx_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'combo',
                                x: 540,
                                y: 80,
                                width: 80,
                                name: 'jfsj',
                                store: jf_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all'
                            }
                            /*,
                            {
                                xtype: 'combo',
                                x: 630,
                                y: 80,
                                width: 50,
                                name: 'gs',
                                store: gs_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all',
                                value:'公盘'
                            }*/
                        ]
                    },
                    {
                        xtype: 'fieldset',
                        layout: 'absolute',
                        width: 710,
                        height: 165,
                        y: 123,
                        x: 0,
                        items: [
                            {
                                xtype: 'combo',
                                x: 40,
                                y: 0,
                                width: 70,
                                name: 'jy',
                                store: cz_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'value',
                                displayField:'text',
                                triggerAction:'all',
                                value:'出租'
                            },
                            {
                                xtype: 'combo',
                                x: 150,
                                y: 0,
                                width: 70,
                                name: 'zt',
                                store: zt_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all',
                                value:'有效'
                            },
                            {
                                xtype: 'label',
                                text: '交易',
                                x: 10,
                                y: 0
                            },
                            {
                                xtype: 'label',
                                text: '状态:',
                                x: 120,
                                y: 0
                            },
                            {
                                xtype: 'checkbox',
                                x: 260,
                                y: 0,
                                boxLabel: '自行',
                                name: 'gs'
                            },
                            {
                                xtype: 'checkbox',
                                x: 310,
                                y: 0,
                                boxLabel: '已签合同',
                                name: 'yzk'
                            },
                            {
                                xtype: 'button',
                                x: 400,
                                y: 0,
                                text: '合同',
                                handler: function(){
                                  var gsm = Ext.getCmp('cz-house-grid').getSelectionModel();
                                  add_contract(gsm);
                                }
                            },                            
                            {
                                xtype: 'label',
                                text: '售价',
                                x: 10,
                                y: 30
                            },
                            {
                                xtype: 'label',
                                text: '包税费',
                                x: 310,
                                y: 30
                            },
                            {
                                xtype: 'label',
                                text: '万元',
                                x: 110,
                                y: 30,
                                width: 30
                            },
                            {
                                xtype: 'label',
                                text: '售底价',
                                x: 170,
                                y: 30
                            },
                            {
                                xtype: 'label',
                                text: '租价',
                                x: 10,
                                y: 60
                            },
                            {
                                xtype: 'label',
                                text: '元/月/平米',
                                x: 110,
                                y: 60,
                                width: 60
                            },
                            {
                                xtype: 'label',
                                text: '租底价',
                                x: 170,
                                y: 60
                            },
                            {
                                xtype: 'label',
                                text: '电功率',
                                x: 310,
                                y: 60
                            },
                            {
                                xtype: 'label',
                                text: '委托',
                                x: 10,
                                y: 90
                            },
                            {
                                xtype: 'label',
                                text: '委托方式',
                                x: 160,
                                y: 90
                            },
                            {
                                xtype: 'label',
                                text: '管理费',
                                x: 310,
                                y: 90
                            },
                            {
                                xtype: 'label',
                                text: '到期',
                                x: 10,
                                y: 120
                            },
                            {
                                xtype: 'label',
                                text: '委托编号',
                                x: 160,
                                y: 120
                            },
                            {
                                xtype: 'label',
                                text: '来源',
                                x: 320,
                                y: 120
                            },
                            {
                                xtype: 'label',
                                text: '现状',
                                x: 450,
                                y: 0
                            },
                            {
                                xtype: 'label',
                                text: '产权',
                                x: 570,
                                y: 0
                            },
                            {
                                xtype: 'label',
                                text: '围墙',
                                x: 450,
                                y: 30
                            },
                            {
                                xtype: 'label',
                                text: '证件',
                                x: 570,
                                y: 30
                            },
                            {
                                xtype: 'label',
                                text: '配套',
                                x: 450,
                                y: 60
                            },
                            {
                                xtype: 'label',
                                text: '租金',
                                x: 570,
                                y: 60
                            },
                            {
                                xtype: 'label',
                                text: '宿舍',
                                x: 450,
                                y: 90
                            },
                            {
                                xtype: 'label',
                                text: '付佣',
                                x: 570,
                                y: 90
                            },
                            {
                                xtype: 'label',
                                text: '食堂',
                                x: 450,
                                y: 120
                            },
                            {
                                xtype: 'label',
                                text: '看房',
                                x: 570,
                                y: 120
                            },
                            {
                                xtype: 'container',
                                x: 385,
                                y: -10,
                                width: 30,
                                height: 30,
                                autoEl: '租'
                            },
                            {
                                xtype: 'textfield',
                                x: 40,
                                y: 30,
                                width: 70,
                                name: 'szj'
                            },
                            {
                                xtype: 'textfield',
                                x: 210,
                                y: 30,
                                width: 70,
                                name: 'sdj'
                            },
                            {
                                xtype: 'combo',
                                x: 350,
                                y: 30,
                                width: 70,
                                name: 'tax',
                                store: tax_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all',
                                value:'不包税费'
                            },
                            {
                                xtype: 'textfield',
                                x: 40,
                                y: 60,
                                width: 70,
                                name: 'zzj'
                            },
                            {
                                xtype: 'textfield',
                                x: 210,
                                y: 60,
                                width: 70,
                                name: 'zdj'
                            },
                            {
                                xtype: 'textfield',
                                x: 350,
                                y: 60,
                                width: 70,
                                name: 'dgl'
                            },
                            {
                                xtype: 'datefield',
                                x: 40,
                                y: 90,
                                width: 110,
                                format: 'Y-m-d',
                                name: 'create_at',
                                value: (new Date()).format('Y-m-d')
                            },
                            {
                                xtype: 'combo',
                                x: 210,
                                y: 90,
                                width: 70,
                                name: 'wtfs',
                                store: wt_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text'
                            },
                            {
                                xtype: 'textfield',
                                x: 350,
                                y: 90,
                                width: 70,
                                name: 'glf'
                            },
                            {
                                xtype: 'datefield',
                                x: 40,
                                y: 120,
                                width: 110,
                                format:'Y-m-d',
                                name: 'wtdq',
                                value: (new Date()).format('Y-m-d')
                            },
                            {
                                xtype: 'textfield',
                                x: 210,
                                y: 120,
                                width: 70,
                                name: 'wtbh'
                            },
                            {
                                xtype: 'combo',
                                x: 350,
                                y: 120,
                                width: 70,
                                name: 'fwly',
                                store: xxly_store,
                                emptyText:'请选择',
                                mode: 'remote',
                                valueField:'value',
                                displayField:'value',
                                triggerAction: 'all'
                            },
                            {
                                xtype: 'combo',
                                x: 480,
                                y: 0,
                                width: 80,
                                name: 'fwxz',
                                store: xz_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction: 'all'
                            },
                            {
                                xtype: 'combo',
                                x: 600,
                                y: 0,
                                width: 80,
                                name: 'fwcq',
                                store: cq_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction: 'all'
                            },
                            {
                                xtype: 'combo',
                                x: 480,
                                y: 30,
                                width: 80,
                                name: 'fwwq',
                                store: fwwq_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'combo',
                                x: 600,
                                y: 30,
                                width: 80,
                                name: 'fwzj',
                                store: fyzj_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'combo',
                                x: 480,
                                y: 60,
                                width: 80,
                                name: 'fwpt',
                                store: pt_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text'
                            },
                            {
                                xtype: 'combo',
                                x: 600,
                                y: 60,
                                width: 80,
                                name: 'czfs',
                                store: czfs_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'combo',
                                x: 480,
                                y: 90,
                                width: 80,
                                name: 'fwss',
                                store: fwrs_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'value',
                                displayField:'text',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'combo',
                                x: 600,
                                y: 90,
                                width: 80,
                                name: 'fyfs',
                                store: fyfs_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'combo',
                                x: 480,
                                y: 120,
                                width: 80,
                                name: 'fwst',
                                store: fwrs_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'value',
                                displayField:'text',
                                triggerAction:'all'
                            },
                            {
                                xtype: 'combo',
                                x: 600,
                                y: 120,
                                width: 80,
                                name: 'kf',
                                store: key_store,
                                emptyText:'请选择',
                                mode: 'local',
                                valueField:'text',
                                displayField:'text',
                                triggerAction:'all'
                            }
                        ]
                    },
                    {
                        xtype: 'textfield',
                        x: 50,
                        y: 300,
                        width: 140,
                        name: 'khxm'
                    },
                /*    {
                        xtype: 'button',
                        text: '查找',
                        x: 160,
                        y: 300,
                        width: 20,
                        handler: function() {
                          search_lxr();
                        }
                    },
                */    {
                        xtype: 'textfield',
                        x: 220,
                        y: 300,
                        width: 140,
                        name: 'khdh',
                        allowBlank: false,
                        listeners:{
                          scope: this,
                          'blur': function(field){
                            if (field.getValue() != field.startValue){
                              var pars = {mobile:field.getValue()};
                              new Ajax.Request("/desktop/check_khxx_mobile", 
                                { method: "POST",
                                  parameters: pars,
                                  onComplete:  function(request) {
                                    var users = eval("("+request.responseText+")");
                                    if (users.size() > 0) {
                                      //field.startValue='';
                                      //field.setValue('');
                                      //Ext.Msg.alert("错误","用户已经存在！");
                                      
                                      Ext.Msg.confirm("确认", "用户已经存在, 确定使用？", 
                                        function(btn){
                                          if (btn=='yes') {
                                            select = users[0].users;
                                            var cz_form = Ext.getCmp('czxx_add_form').form;
                                            cz_form.findField('kh_id').setValue(select['id']);
                                            cz_form.findField('khxm').setValue(select['gsmc']);
                                            cz_form.findField('khlxr').setValue(select['lxr']);
                                            cz_form.findField('khsfz').setValue(select['khsfz']);
                                            cz_form.findField('khdh').setValue(select['mobile']);
                                            cz_form.findField('khdz').setValue(select['address']);                                          
                                          }
                                          else {
                                            field.startValue='';
                                            field.setValue('');
                                          }
                                        }
                                      );
                                      
                                    } 
                                  }
                                });                                       
                            }
                          }
                        }
                    },
                    {
                        xtype: 'textfield',
                        x: 50,
                        y: 330,
                        width: 140,
                        name: 'khlxr'
                    },
                    {
                        xtype: 'textfield',
                        x: 50,
                        y: 360,
                        width: 140,
                        name: 'khsfz'
                    },
                    {
                        xtype: 'combo',
                        x: 50,
                        y: 390,
                        width: 140,
                        store: gj_store,
                        name: 'khgj',
                        emptyText:'请选择',
                        mode: 'local',
                        valueField:'text',
                        displayField:'text',
                        triggerAction : 'all'
                    },
                    {
                        xtype: 'textarea',
                        x: 220,
                        y: 330,
                        width: 170,
                        height: 80,
                        name: 'lxfs'
                    },
                    {
                        xtype: 'textarea',
                        x: 490,
                        y: 300,
                        width: 200,
                        height: 100,
                        name: 'bz'
                    },
                    {
                        xtype: 'combo',
                        x: 490,
                        y: 410,
                        width: 100,
                        name: 'ygbm',
                        store: bm_store,
                        emptyText:'请选择',
                        mode: 'local',
                        valueField:'text',
                        displayField:'text',
                        triggerAction:'all',
                        listeners:{
                          scope: this,
                          'select': function(combo){
                            yg_store.baseParams={bm:combo.getValue()};
                            yg_store.load();
                          }
                        }
                    },
                    {
                        xtype: 'combo',
                        x: 590,
                        y: 410,
                        width: 100,
                        name: 'ygxm',
                        store: yg_store,
                        emptyText:'请选择',
                        mode: 'local',
                        valueField:'text',
                        displayField:'text'
                    },
                    {
                        xtype: 'label',
                        text: '备注',
                        x: 460,
                        y: 300
                    },
                    {
                        xtype: 'label',
                        text: '员工',
                        x: 460,
                        y: 410
                    },
                    {
                        xtype: 'label',
                        text: '业主',
                        x: 20,
                        y: 300
                    },
                    {
                        xtype: 'label',
                        text: '手机',
                        x: 195,
                        y: 300
                    },
                    {
                        xtype: 'label',
                        text: '联系人',
                        x: 10,
                        y: 330
                    },
                    {
                        xtype: 'label',
                        text: '身份证',
                        x: 10,
                        y: 360
                    },
                    {
                        xtype: 'label',
                        text: '国籍',
                        x: 20,
                        y: 390
                    },
                    {
                        xtype: 'button',
                        text: 'SMS',
                        x: 360,
                        y: 300
                    },
                    {
                        xtype: 'textfield',
                        hidden : true,
                        name : 'id'                     
                    },
                    {
                        xtype: 'textfield',
                        hidden : true,
                        name : 'kh_id'
                    },
                    {
                        xtype: 'textfield',
                        hidden : true,
                        name : 'yg_id'                      
                    },
                    {
                        xtype: 'textfield',
                        hidden : true,
                        name : 'wyzd_id'                      
                    },
                    {
                      layout:"absolute",
                      xtype: 'grid',
                      x: 10,
                      y: 300,
                      id: 'czxx_gj_grid',
                      width: 420,
                      height : 132,
                      stripeRows: true,
                      store: Ext.getCmp('czxx-view').czgjStore,
                      columns: [
                         // {id:'id',header: 'id', width: 20, hidden: true, dataIndex: 'id', sortable: true},
                         {header: '跟进信息',   width: 200, sortable: true, dataIndex: 'message'},
                         {header: '部门',     width: 50, sortable: true,  dataIndex: 'ygbm'},
                         {header: '跟进人',    width: 50, sortable: true,  dataIndex: 'ygxm'},
                         {header: '最后更新日期', width: 100, sortable: true,  renderer: Ext.util.Format.dateRenderer('Y-m-d'), dataIndex: 'create_at'}
                      ],
                      viewConfig: {
                          forceFit:true,
                          enableRowBody:true,
                          showPreview : true,
                          getRowClass : function(record, rowIndex, p, ds) {
                              if (this.showPreview) {
                                  var xf = Ext.util.Format;
                                  p.body = '<p>' + xf.ellipsis(xf.stripTags(record.data.message), 200) + '</p>';
                                  return 'x-grid3-row-expanded';
                              }
                              return 'x-grid3-row-collapsed';
                          }
                      }
                    },
                    {
                      layout:"absolute",
                      xtype: 'grid',
                      x: 10,
                      y: 300,
                      id: 'czxx_dk_grid',
                      width: 420,
                      height : 132,
                      //stripeRows: true,
                      store: Ext.getCmp('czxx-view').dkgjStore,
                      columns: [
                         // {id:'id',header: 'id', width: 20, hidden: true, dataIndex: 'id', sortable: true},
                         {header: '带看信息',   width: 150, sortable: true, dataIndex: 'message'},
                         {header: '带看人',    width: 50, sortable: true,  dataIndex: 'yg_xm'},
                         {header: '客户',     width: 50, sortable: true,  dataIndex: 'qz_xm'},
                         {header: '接待人',    width: 50, sortable: true,  dataIndex: 'cz_xm'},
                         {header: '带看合同',   width: 50, sortable: true,  dataIndex: 'dkht'},
                         {header: '带看时间',   width: 100, sortable: true,  renderer: Ext.util.Format.dateRenderer('Y-m-d'), dataIndex: 'visit_at'}
                      ]
                    }
                ],
            buttons:[
            {
              text: '写跟进',
              handler: function(){
                var text = Ext.getCmp('czxx_add_form').buttons[0].getText();
                if (text == '写跟进') {
                  action2.execute();
                } else if (text == '写带看'){
                  action6.execute();
                }
              }
            },
            {
              text: '删除',
              handler: function(){
                var text = Ext.getCmp('czxx_add_form').buttons[0].getText();
                if (text == '写跟进') {
                  var data = Ext.getCmp('czxx_gj_grid').getSelectionModel().getSelected().data;
                  var pars={id:data.id}
                  new Ajax.Request("/desktop/delete_czgj", 
                    { method: "POST",
                      parameters: pars,
                      onComplete:  function(request) {
                        Ext.getCmp('czxx_gj_grid').store.reload();
                      }
                    });               
                } else if (text == '写带看'){
                  var data = Ext.getCmp('czxx_dk_grid').getSelectionModel().getSelected().data;
                  var pars={id:data.id}
                  new Ajax.Request("/desktop/delete_dkgj", 
                    { method: "POST",
                      parameters: pars,
                      onComplete:  function(request) {
                        Ext.getCmp('czxx_dk_grid').store.reload();
                      }
                    });               
                }               

              }
            },
            {
              text: '上一个',
              handler: function(){
                gsm.selectPrevious();
                var data = gsm.getSelected();
                var form = Ext.getCmp("czxx_add_form").getForm();
                form.loadRecord(data);
                if (currentUser.prev_code[12] == 't') 
                  test_win.setTitle('修改房源 - '+data.data.khxm)
                else 
                  test_win.setTitle('查看房源 - '+data.data.khxm);            
              }
            },
            {
              text: '下一个',
              handler: function(){
                gsm.selectNext();
                var data = gsm.getSelected();
                var form = Ext.getCmp("czxx_add_form").getForm();
                form.loadRecord(data);
                if (currentUser.prev_code[12] == 't') 
                  test_win.setTitle('修改房源 - '+data.data.khxm)
                else 
                  test_win.setTitle('查看房源 - '+data.data.khxm);            
              }
            },
            {
              text: '切换',
              handler: function(){
                if ( Ext.getCmp('czxx_gj_grid').isVisible() ){
                  Ext.getCmp('czxx_gj_grid').hide();
                  Ext.getCmp('czxx_dk_grid').show();
                  Ext.getCmp('czxx_add_form').buttons[0].show();
                  Ext.getCmp('czxx_add_form').buttons[1].show();
                  Ext.getCmp('czxx_add_form').buttons[0].setText('写带看')   
                } else if ( Ext.getCmp('czxx_dk_grid').isVisible() ) {
                  Ext.getCmp('czxx_gj_grid').hide();
                  Ext.getCmp('czxx_dk_grid').hide();
                  Ext.getCmp('czxx_add_form').buttons[0].hide();
                  Ext.getCmp('czxx_add_form').buttons[1].hide();        
                } else {
                  Ext.getCmp('czxx_gj_grid').show();
                  Ext.getCmp('czxx_dk_grid').hide();
                  Ext.getCmp('czxx_add_form').buttons[0].show();
                  Ext.getCmp('czxx_add_form').buttons[1].show();        
                  Ext.getCmp('czxx_add_form').buttons[0].setText('写跟进')   
                }
              }             
            },
            {
              text: '保存',
              handler: function(){
                var pars = Ext.getCmp("czxx_add_form").getForm().getValues();
                new Ajax.Request("/desktop/save_czxx", 
                  { method: "POST",
                    parameters: pars,
                    onComplete:  function(request) {
                      test_win.close();
                      Ext.getCmp('grid-win').show();
                      //reload
                      if (gsm != undefined) {
                        gsm.grid.store.reload();
                        gsm.selectRow(gsm.grid.store.indexOfId(czxx_id), true);
                      } else {
                        //test_win.close();
                        Ext.getCmp('czxx-view').gsm.grid.store.reload();
                      }
                    }
                  });
              }
            },{
              text: '取消',
              handler: function(){
                test_win.close();
                Ext.getCmp('grid-win').show();
              }
            }]
          }]
      });
      
      test_win.on('close', function(){
        Ext.getCmp('grid-win').show();
      });
      
      if (gsm != undefined) {
        var data = gsm.getSelected();
        var form = Ext.getCmp("czxx_add_form").getForm();

        if (data.data.mpdh == '') data.data.mpdh = '0';
        if (data.data.lc == '')   data.data.lc = '0';
        if (data.data.zc == '')   data.data.zc = '0';
        if (data.data.cfmj == '') data.data.cfmj = '0';
        if (data.data.ssmj == '') data.data.ssmj = '0';
        if (data.data.bgmj == '') data.data.bgmj = '0';
        if (data.data.kdmj == '') data.data.kdmj = '0';
        if (data.data.length == '') data.data.length = '0';
        if (data.data.width == '')  data.data.width = '0';
        if (data.data.height == '') data.data.height = '0';
        if (data.data.zmj == '') data.data.zmj = '0';
        if (data.data.cs == '')  data.data.cs = '0';
        if (data.data.szj == '') data.data.szj = '0';
        if (data.data.sdj == '') data.data.sdj = '0';
        if (data.data.zzj == '') data.data.zzj = '0';
        if (data.data.zdj == '') data.data.zdj = '0';
        if (data.data.dgl == '') data.data.dgl = '0';
        
        form.loadRecord(data);
        
        if (currentUser.prev_code[12] == 't') 
          test_win.setTitle('修改房源 - '+data.data.khxm)
        else 
          test_win.setTitle('查看房源 - '+data.data.khxm);
          
        test_win.setIconClass('new');
        Ext.getCmp('czxx_add_form').buttons[0].show();
        Ext.getCmp('czxx_add_form').buttons[1].show();
        
        //hide save button 
        if (currentUser.prev_code[12] != 't') {
          Ext.getCmp('czxx_add_form').buttons[5].hide();
        }
        
        Ext.getCmp('czxx_dk_grid').hide();
        
      } else {
        var data = {};
        czxx_id = 0;
        data['yg_id'] = currentUser['id'];
        data['ygxm'] = currentUser['login'];
        data['ygbm'] = currentUser['bm'];
        
        //default value 
        data['mpdh'] = '0';
        data['lc'] = '0';
        data['zc'] = '0';
        data['cfmj'] = '0';
        data['ssmj'] = '0';
        data['bgmj'] = '0';
        data['kdmj'] = '0';
        data['length'] = '0';
        data['width'] = '0';
        data['height'] = '0';
        data['zmj'] = '0';
        data['cs'] = '0';
        data['szj'] = '0';
        data['sdj'] = '0';
        data['zzj'] = '0';
        data['zdj'] = '0';
        data['dgl'] = '0';
        
        var form = Ext.getCmp("czxx_add_form").getForm();
        form.setValues(data);
        test_win.setTitle('新增房源');
        test_win.setIconClass('add2');
        Ext.getCmp('czxx_add_form').buttons[0].hide();
        Ext.getCmp('czxx_add_form').buttons[1].hide();        
        Ext.getCmp('czxx_add_form').buttons[2].hide();
        Ext.getCmp('czxx_add_form').buttons[3].hide();  
        Ext.getCmp('czxx_add_form').buttons[4].hide();  
        Ext.getCmp('czxx_dk_grid').hide();
        Ext.getCmp('czxx_gj_grid').hide();
      };

      test_win.show();
      test_win.setZIndex(9020);     
    };
    
    var action1 = new Ext.Action({
        text: '看详细',
        handler: function(){
            add_czxx(Ext.getCmp('czxx-view').gsm);  
        }
        //iconCls: 'blist'
    });

    var action2 = new Ext.Action({
        text: '写跟进',
        handler: function(){
            //if (!Ext.getCmp('czxx_gj_grid').isVisible()) Ext.getCmp('czxx_gj_grid').show();
            
            var track_win = new Ext.Window({
                title: '写跟进',
                floating: true,
                shadow: true,
                draggable: true,
                closable: true,
                modal: true,
                width: 430,
                height: 360,
                layout: 'fit',
                plain: true,
                items: [{
                  xtype:"form",
                  id : 'cz_track_win_form',
                  width: 422,
                  height: 326,
                  padding: 10,
                  layout: 'absolute',
                  items:[
                      {
                          xtype: 'label',
                          text: '时间方式',
                          x: 20,
                          y: 10
                      },
                      {
                          xtype: 'label',
                          text: '部门员工',
                          x: 20,
                          y: 40
                      },
                      {
                          xtype: 'label',
                          text: '跟进内容',
                          x: 20,
                          y: 70
                      },
                      {
                          xtype: 'label',
                          text: '下次提醒',
                          x: 20,
                          y: 180
                      },
                      {
                          xtype: 'label',
                          text: '提醒范围',
                          x: 20,
                          y: 210
                      },
                      {
                          xtype: 'label',
                          text: '提醒内容',
                          x: 20,
                          y: 240
                      },
                      {
                          xtype: 'datefield',
                          x: 90,
                          y: 10,
                          name: 'sjfs',
                          format:"Y-m-d",
                          emptyText:'(系统时间)',
                          width:150,
                          value: (new Date()).format('Y-m-d')
                      },
                      {
                          xtype: 'textfield',
                          x: 90,
                          y: 40,
                          name: 'bmyg',
                          value: currentUser.login,
                          width:150
                      },
                      {
                          xtype: 'textarea',
                          x: 90,
                          y: 70,
                          anchor: '',
                          width: 300,
                          height: 100,
                          name: 'gjnr'
                      },
                      {
                          xtype: 'datefield',
                          x: 90,
                          y: 180,
                          width: 100,
                          name: 'gjrq',
                          format:"Y-m-d",
                          value: (new Date()).format('Y-m-d')
                      },
                      {
                          xtype: 'timefield',
                          x: 200,
                          y: 180,
                          width: 80,
                          minValue: '9:00 AM',
                          maxValue: '6:00 PM',
                          increment: 30,
                          name: 'gjsj',
                          value: (new Date()).format('H:i A')
                      },
                      {
                          xtype: 'combo',
                          x: 90,
                          y: 210,
                          name: 'txfw',
                          mode  : "local", 
                          store : txfw_store,
                          displayField: 'text', 
                          valueField: 'text',
                          triggerAction : 'all',
                          emptyText : '请选择',
                          value: '不提醒',
                          width:150
                      },
                      {
                          xtype: 'textfield',
                          x: 90,
                          y: 240,
                          width: 300,
                          name: 'txnr'
                      }
                  ],
                  buttons:[{
                    text: '保存',
                    handler: function(){
                      var pars = Ext.getCmp("cz_track_win_form").getForm().getValues();
                      pars['yg_id']=currentUser.id;
                      pars['ygbm']=currentUser.bm;
                      pars['ygxm']=currentUser.login;
                      pars['czxx_id']=czxx_id;
                      var now = new Date();
                      pars['create_at']=now.format('Y-m-d H:i:s');
                      
                      new Ajax.Request("/desktop/add_czgj", { 
                        method: "POST",
                        parameters: pars,
                        onComplete:  function(request) {
                          track_win.close();
                          
                          //reload track window
                          Ext.getCmp('czxx-view').czgjStore.baseParams = {id:czxx_id}
                          Ext.getCmp('czxx-view').czgjStore.load();
                        }
                      });
                    }
                  },{
                    text: '取消',
                    handler: function(){
                      track_win.close();
                    }
                  }]
                }]
            });
            
            track_win.show();
            track_win.setZIndex(9020);  
        }
    });

    var action3 = new Ext.Action({
        text: '查字典',
        handler: function(){
          var gsm = Ext.getCmp('cz-house-grid').getSelectionModel();
          add_wyzd(gsm);
        }
    });

    var action4 = new Ext.Action({
        text: '看客户',
        /*
        handler: function(){
            //msg('Click','You clicked on "查地图".');
            window.open("/draw/DrawBuild.swf","绘制草图");
        }
        */
        handler: function(){
            //msg('Click','You clicked on "写跟进".');
            var track_win = new Ext.Window({
                title: '客户信息',
                floating: true,
                shadow: true,
                draggable: true,
                closable: true,
                modal: true,
                width: 518,
                height: 395,
                layout: 'fit',
                plain: true,
                items: [{
                  xtype:"form",
                  id : 'cz_customer_add_form',
                  width: 518,
                  height: 395,
                  padding: 10,
                  layout: 'absolute',
                  items:[{
                      xtype: 'tabpanel',
                      deferredRender: false,
                      activeTab: 0,
                      width: 500,
                      height: 320,
                      items: [
                          {
                              xtype: 'panel',
                              title: '客户信息',
                              layout: 'absolute',
                              width: 536,
                              height: 409,
                              items: [
                                  {
                                      xtype: 'textfield',
                                      hidden : true,
                                      name : 'id'
                                  },
                                  {
                                      xtype: 'label',
                                      text: '客户编号',
                                      x: 20,
                                      y: 10
                                  },
                                  {
                                      xtype: 'label',
                                      text: '联系人',
                                      x: 20,
                                      y: 40
                                  },
                                  {
                                      xtype: 'label',
                                      text: '职位',
                                      x: 20,
                                      y: 70
                                  },
                                  {
                                      xtype: 'label',
                                      text: '行业',
                                      x: 20,
                                      y: 100
                                  },
                                  {
                                      xtype: 'label',
                                      text: '移动电话',
                                      x: 20,
                                      y: 130
                                  },
                                  {
                                      xtype: 'label',
                                      text: 'iPhone',
                                      x: 20,
                                      y: 160
                                  },
                                  {
                                      xtype: 'label',
                                      text: '小灵通',
                                      x: 20,
                                      y: 190
                                  },
                                  {
                                      xtype: 'label',
                                      text: '家庭电话',
                                      x: 20,
                                      y: 220
                                  },
                                  {
                                      xtype: 'label',
                                      text: '其他电话',
                                      x: 20,
                                      y: 250
                                  },
                                  {
                                      xtype: 'label',
                                      text: '客户类别',
                                      x: 260,
                                      y: 10
                                  },
                                  {
                                      xtype: 'label',
                                      text: '电子邮件',
                                      x: 260,
                                      y: 40
                                  },
                                  {
                                      xtype: 'label',
                                      text: '生日',
                                      x: 260,
                                      y: 70
                                  },
                                  {
                                      xtype: 'label',
                                      text: '个人爱好',
                                      x: 260,
                                      y: 100
                                  },
                                  {
                                      xtype: 'label',
                                      text: '子女情况',
                                      x: 260,
                                      y: 130
                                  },
                                  {
                                      xtype: 'label',
                                      text: '家庭地址',
                                      x: 260,
                                      y: 160
                                  },
                                  {
                                      xtype: 'label',
                                      text: '备注',
                                      x: 260,
                                      y: 190
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 10,
                                      width: 150,
                                      name: 'khbh'
                                  },
                                  {
                                      xtype: 'combo',
                                      x: 320,
                                      y: 10,
                                      width: 150,
                                      name: 'khlb',
                                      store: khlb_store,
                                      emptyText:'',
                                      mode: 'remote',
                                      minChars : 2,
                                      valueField:'value',
                                      displayField:'value',
                                      triggerAction:'all'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 40,
                                      width: 150,
                                      name: 'lxr'
                                  },
                                  {
                                      xtype: 'combo',
                                      x: 80,
                                      y: 70,
                                      width: 150,
                                      name: 'zw',
                                      store: zwbh_store,
                                      emptyText:'',
                                      mode: 'remote',
                                      minChars : 2,
                                      valueField:'value',
                                      displayField:'value',
                                      triggerAction:'all'                 
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 100,
                                      width: 150,
                                      name: 'hy'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 130,
                                      width: 150,
                                      name: 'mobile'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 160,
                                      width: 150,
                                      name: 'iphone'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 190,
                                      width: 150,
                                      name: 'linktone'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 220,
                                      width: 150,
                                      name: 'jtdh1'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 250,
                                      width: 150,
                                      name: 'jtdh2'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 320,
                                      y: 40,
                                      width: 150,
                                      name: 'email'
                                  },
                                  {
                                      xtype: 'datefield',
                                      x: 320,
                                      y: 70,
                                      width: 150,
                                      format: 'Y-m-d',
                                      name: 'birthday'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 320,
                                      y: 100,
                                      width: 150,
                                      name: 'hobby'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 320,
                                      y: 130,
                                      width: 150,
                                      name: 'children'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 320,
                                      y: 160,
                                      width: 150,
                                      name: 'jtdz'
                                  },
                                  {
                                      xtype: 'textarea',
                                      x: 320,
                                      y: 190,
                                      width: 150,
                                      anchor: '',
                                      height: 80,
                                      name: 'bz'
                                  }
                              ]
                          },
                          {
                              xtype: 'panel',
                              title: '公司信息',
                              layout: 'absolute',
                              items: [
                                  {
                                      xtype: 'label',
                                      text: '公司名称',
                                      x: 20,
                                      y: 10
                                  },
                                  {
                                      xtype: 'label',
                                      text: '公司规模',
                                      x: 20,
                                      y: 40
                                  },
                                  {
                                      xtype: 'label',
                                      text: '公司全名',
                                      x: 20,
                                      y: 70
                                  },
                                  {
                                      xtype: 'label',
                                      text: '电话1',
                                      x: 20,
                                      y: 100
                                  },
                                  {
                                      xtype: 'label',
                                      text: '电话2',
                                      x: 20,
                                      y: 130
                                  },
                                  {
                                      xtype: 'label',
                                      text: '传真',
                                      x: 20,
                                      y: 160
                                  },
                                  {
                                      xtype: 'label',
                                      text: '网址',
                                      x: 20,
                                      y: 190
                                  },
                                  {
                                      xtype: 'label',
                                      text: '地址',
                                      x: 20,
                                      y: 220
                                  },
                                  {
                                      xtype: 'label',
                                      text: '邮编',
                                      x: 20,
                                      y: 250
                                  },
                                  {
                                      xtype: 'label',
                                      text: '开户银行',
                                      x: 260,
                                      y: 10
                                  },
                                  {
                                      xtype: 'label',
                                      text: '银行账号',
                                      x: 260,
                                      y: 40
                                  },
                                  {
                                      xtype: 'label',
                                      text: '税务登记号',
                                      x: 260,
                                      y: 70
                                  },
                                  {
                                      xtype: 'label',
                                      text: '所有制类型',
                                      x: 260,
                                      y: 100
                                  },
                                  {
                                      xtype: 'label',
                                      text: '客户级别',
                                      x: 260,
                                      y: 130
                                  },
                                  {
                                      xtype: 'label',
                                      text: '金土地内评',
                                      x: 260,
                                      y: 160
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 10,
                                      width: 150,
                                      name: 'gsmc'
                                  },
                                  {
                                      xtype: 'combo',
                                      x: 80,
                                      y: 40,
                                      width: 150,
                                      name: 'gsgm',
                                      store: gsgm_store,
                                      emptyText:'',
                                      mode: 'remote',
                                      minChars : 2,
                                      valueField:'value',
                                      displayField:'value',
                                      triggerAction:'all'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 70,
                                      width: 150,
                                      name: 'gsqm'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 100,
                                      width: 150,
                                      name: 'bgdh1'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 130,
                                      width: 150,
                                      name: 'bgdh2'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 160,
                                      width: 150,
                                      name: 'bgcz'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 190,
                                      width: 150,
                                      name: 'gsweb'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 220,
                                      width: 150,
                                      name: 'address'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 80,
                                      y: 250,
                                      width: 150,
                                      name: 'zip'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 330,
                                      y: 10,
                                      width: 150,
                                      name: 'khyh'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 330,
                                      y: 40,
                                      width: 150,
                                      name: 'yhzh'
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 330,
                                      y: 70,
                                      width: 150,
                                      name: 'swdjh'
                                  },
                                  {
                                      xtype: 'combo',
                                      x: 330,
                                      y: 100,
                                      width: 150,
                                      name: 'syzlx',
                                      store: syzlx_store,
                                      emptyText:'',
                                      mode: 'remote',
                                      minChars : 2,
                                      valueField:'value',
                                      displayField:'value',
                                      triggerAction:'all'                 
                                  },
                                  {
                                      xtype: 'combo',
                                      x: 330,
                                      y: 130,
                                      width: 150,
                                      name: 'khjb',
                                      store: khjb_store,
                                      emptyText:'',
                                      mode: 'remote',
                                      minChars : 2,
                                      valueField:'value',
                                      displayField:'value',
                                      triggerAction:'all'                 
                                  },
                                  {
                                      xtype: 'textfield',
                                      x: 330,
                                      y: 160,
                                      width: 150,
                                      name: 'jtdnp'
                                  }
                              ]
                          }
                      ]
                  }],
                  buttons:[{
                    text: '保存',
                    handler: function(){
                      var pars = Ext.getCmp("cz_customer_add_form").getForm().getValues();
                      pars['czxx_id']=czxx_id;

                      new Ajax.Request("/desktop/add_customer", { 
                        method: "POST",
                        parameters: pars,
                        onComplete:  function(request) {
                          track_win.close();
                        }
                      });
                    }
                  },{
                    text: '取消',
                    handler: function(){
                      track_win.close();
                    }
                  }]
                }]
            });
            
            var pars = {czxx_id:czxx_id};
            new Ajax.Request("/desktop/set_customer", { 
              method: "POST",
              parameters: pars,
              onComplete:  function(request) {
                var users = eval("("+request.responseText+")");
                if (users.size() > 0) {
                  Ext.getCmp("cz_customer_add_form").getForm().setValues(users[0].users);
                } 
                
                //show the window
                //track_win.show();
              }
            });
            track_win.show();           
        }
        //iconCls: 'blist'
    });

    var action5 = new Ext.Action({
        text: '看带看',
        handler: function(){
          if (dkgjGrid.isVisible()) {
            dkgjGrid.hide();
            czgjGrid.show();
            action5.setText('看带看');
          } else {
            dkgjGrid.show();
            czgjGrid.hide();
            action5.setText('看跟进');
          }
        }
        //iconCls: 'blist'
    });

    var action6 = new Ext.Action({
        text: '写带看',
        handler: function(){
          //  if (!Ext.getCmp('czxx_dk_grid').isVisible()) Ext.getCmp('czxx_dk_grid').show();
            
            var track_win = new Ext.Window({
                title: '写带看',
                floating: true,
                shadow: true,
                draggable: true,
                closable: true,
                modal: true,
                width: 430,
                height: 360,
                layout: 'fit',
                plain: true,
                items: [{
                  xtype:"form",
                  id : 'czdk_track_win_form',
                  width: 422,
                  height: 326,
                  padding: 10,
                  layout: 'absolute',
                  items:[
                      {
                          xtype: 'label',
                          text: '合同编号',
                          x: 20,
                          y: 10
                      },
                      {
                          xtype: 'label',
                          text: '客源编号',
                          x: 20,
                          y: 40
                      },
                      {
                          xtype: 'label',
                          text: '带看时间',
                          x: 20,
                          y: 70
                      },
                      {
                          xtype: 'label',
                          text: '带看人',
                          x: 30,
                          y: 100
                      },
                      {
                          xtype: 'label',
                          text: '客户名',
                          x: 30,
                          y: 130
                      },
                      {
                          xtype: 'label',
                          text: '接待人',
                          x: 30,
                          y: 160
                      },
                      {
                          xtype: 'label',
                          text: '带看内容',
                          x: 20,
                          y: 190
                      },
                      {
                          xtype: 'textfield',
                          x: 90,
                          y: 10,
                          width: 150,
                          name: 'dkht'
                      },
                      {
                          xtype: 'combo',
                          x: 90,
                          y: 40,
                          width: 150,
                          name: 'kyxx',
                          store: ky_store,
                          mode: 'remote',
                          minChars : 2,
                          valueField:'id',
                          displayField:'value',
                          triggerAction:'all'
                      },
                      {
                          xtype: 'datefield',
                          x: 90,
                          y: 70,
                          width: 150,
                          name: 'visit_at',
                          format :'Y-m-d',
                          value: (new Date()).format('Y-m-d')
                      },
                      {
                          xtype: 'textfield',
                          x: 90,
                          y: 100,
                          width: 150,
                          name: 'yg_xm',
                          value: currentUser.login,
                      },
                      {
                          xtype: 'textfield',
                          x: 90,
                          y: 130,
                          width: 150,
                          name: 'qz_xm'
                      },
                      {
                          xtype: 'textfield',
                          x: 90,
                          y: 160,
                          width: 150,
                          name: 'cz_xm'
                      },
                      {
                          xtype: 'textarea',
                          x: 90,
                          y: 190,
                          width: 200,
                          height: 80,
                          name: 'message'
                      }
                  ],
                  buttons:[{
                    text: '保存',
                    handler: function(){
                      var pars = Ext.getCmp("czdk_track_win_form").getForm().getValues();
                      pars['yg_id']=currentUser.id;
                      pars['czxx_id']=czxx_id;
                      pars['kyxx'] = Ext.getCmp('czdk_track_win_form').getForm().items.items[1].getValue();
                      var now = new Date();
                      pars['create_at']=now.format('Y-m-d H:i:s');
                      
                      new Ajax.Request("/desktop/add_dkgj", { 
                        method: "POST",
                        parameters: pars,
                        onComplete:  function(request) {
                          track_win.close();
                          
                          //reload track window
                          Ext.getCmp('czxx-view').dkgjStore.baseParams = {id:czxx_id}
                          Ext.getCmp('czxx-view').dkgjStore.load();
                        }
                      });
                    }
                  },{
                    text: '取消',
                    handler: function(){
                      track_win.close();
                    }
                  }]
                }]
            });
            
            track_win.show();
            track_win.setZIndex(9020);  
        }
    });

    
    this.czgjStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '/desktop/get_czgj'
        }),

        reader: new Ext.data.JsonReader({
          totalProperty: 'results', 
          root: 'rows',             
          fields: [
            {name: 'id'},
            {name: 'create_at', type: 'date', dateFormat: 'Y-m-d H:i:s'},
            {name: 'yg_id',   type: 'string'},                     
            {name: 'ygbm',        type: 'string'},             
            {name: 'ygxm',        type: 'string'},             
            {name: 'message',   type: 'string'},             
            {name: 'txsj',      type: 'string', dateFormat: 'Y-m-d H:i:s'},            
            {name: 'txfw',      type: 'string'},             
            {name: 'txnr',      type: 'string'},             
          ]    
        }),
        sortInfo:{field: 'id', direction: "DESC"}
    });
    
    // create the Grid
    var czgjGrid = new Ext.grid.GridPanel({
        store: this.czgjStore,
        columns: [
           // {id:'id',header: 'id', width: 20, hidden: true, dataIndex: 'id', sortable: true},
           {header: '跟进信息',   width: 250, sortable: true, dataIndex: 'message'},
           {header: '部门',     width: 50, sortable: true,  dataIndex: 'ygbm'},
           {header: '跟进人',    width: 50, sortable: true,  dataIndex: 'ygxm'},
           {header: '最后更新日期', width: 100, sortable: true,  renderer: Ext.util.Format.dateRenderer('Y-m-d'), dataIndex: 'create_at'}
        ],
        height : 150,
        stripeRows: true
        //autoExpandColumn: 'message',
        // config options for stateful behavior
        //stateful: true,
        //stateId: 'grid'        
    });
    
    
    this.dkgjStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '/desktop/get_dkgj'
        }),

        reader: new Ext.data.JsonReader({
          totalProperty: 'results', 
          root: 'rows',             
          fields: [
            {name: 'id'},
            {name: 'create_at', type: 'date', dateFormat: 'Y-m-d H:i:s'},
            {name: 'visit_at',  type: 'date', dateFormat: 'Y-m-d H:i:s'},
            {name: 'dkht',      type: 'string'},   
            {name: 'yg_xm',     type: 'string'}, 
            {name: 'qz_xm',     type: 'string'}, 
            {name: 'cz_xm',     type: 'string'},
            {name: 'czbh',          type: 'string'},
            {name: 'message',   type: 'string'}
          ]    
        }),
        sortInfo:{field: 'id', direction: "DESC"}
    });
    
    
    // create the Grid
    var dkgjGrid = new Ext.grid.GridPanel({
        store: this.dkgjStore,
        columns: [
           // {id:'id',header: 'id', width: 20, hidden: true, dataIndex: 'id', sortable: true},
           {header: '带看信息',   width: 250, sortable: true, dataIndex: 'message'},
           {header: '带看人',    width: 50, sortable: true,  dataIndex: 'yg_xm'},
           {header: '客户',     width: 50, sortable: true,  dataIndex: 'qz_xm'},
           {header: '接待人',    width: 50, sortable: true,  dataIndex: 'cz_xm'},
           {header: '带看合同',   width: 50, sortable: true,  dataIndex: 'dkht'},
           {header: '出租编号',   width: 50, sortable: true,  dataIndex: 'czbh'},
           {header: '带看时间',   width: 100, sortable: true,  renderer: Ext.util.Format.dateRenderer('Y-m-d'), dataIndex: 'visit_at'}
        ],
        height : 150,
        stripeRows: true
        //autoExpandColumn: 'message',
        // config options for stateful behavior
        //stateful: true,
        //stateId: 'grid'        
    });
    
    //dkgjGrid.setVisible(false);
    //czgjGrid.setVisible(false);
    
    dkgjGrid.hide();
    
    CzxxPanel.superclass.constructor.call(this, {
        id:'czxx-view',
        layout:'border',
        //title:'Loading...',
        hideMode:'offsets',
        closable:true,   //!!add this to close this panel
        tbar: [{
                text:'全部房源',
                tooltip:'快速选择时间',
                iconCls:'t0',
                split:true,
                handler: this.toggleTime.createDelegate(this, []),
                menu: 
                {
                    id:'czxx-slelect-menu',
                    cls:'reading-menu',
                    width:100,
                    items: [{
                        text:'全部房源',
                        checked:true,
                        group:'rp-group',
                        checkHandler:this.toggleTime,
                        scope:this,
                        iconCls:'t0'
                    },{
                        text:'今日新房',
                        checked:false,
                        group:'rp-group',
                        checkHandler:this.toggleTime,
                        scope:this,
                        iconCls:'t1'
                    },{
                        text:'最近三天',
                        checked:false,
                        group:'rp-group',
                        checkHandler:this.toggleTime,
                        scope:this,
                        iconCls:'t3'
                    },{
                        text:'最近七天',
                        checked:false,
                        group:'rp-group',
                        checkHandler:this.toggleTime,
                        scope:this,
                        iconCls:'t7'
                    },{
                        text:'最近半月',
                        checked:false,
                        group:'rp-group',
                        checkHandler:this.toggleTime,
                        scope:this,
                        iconCls:'t15'
                    },{
                        text:'最近一月',
                        checked:false,
                        group:'rp-group',
                        checkHandler:this.toggleTime,
                        scope:this,
                        iconCls:'t30'
                    },{
                        text:'最近三月',
                        checked:false,
                        group:'rp-group',
                        checkHandler:this.toggleTime,
                        scope:this,
                        iconCls:'t90'                   
                    },{
                        text:'最近半年',
                        checked:false,
                        group:'rp-group',
                        checkHandler:this.toggleTime,
                        scope:this,
                        iconCls:'t180'
                    }]
                }
            },
            {
                text:'租售',
                tooltip:'快速选择租售',
                iconCls:'option',
                split:true,
                handler: this.toggleType.createDelegate(this, []),
                menu: {
                    id:'czxx-option-menu',
                    cls:'option-menu',
                    width:100,
                    items: [{
                        text:'租售',
                        checked:true,
                        group:'op-group',
                        checkHandler:this.toggleType,
                        scope:this,
                        iconCls:'option'
                    },{
                        text:'出租',
                        checked:false,
                        group:'op-group',
                        checkHandler:this.toggleType,
                        scope:this,
                        iconCls:'tz'
                    },{
                        text:'出售',
                        checked:false,
                        group:'op-group',
                        checkHandler:this.toggleType,
                        scope:this,
                        iconCls:'ts'
                    }]
                }
            },
            {
                text:'全部',
                tooltip:'快速选择状态',
                iconCls:'remove',
                split:true,
                handler: this.toggleState.createDelegate(this, []),
                menu: {
                    id:'czxx-state-menu',
                    cls:'option-menu',
                    width:100,
                    items: [{
                        text:'全部',
                        checked:true,
                        group:'zt-group',
                        checkHandler:this.toggleState,
                        scope:this,
                        iconCls:'option'
                    },{
                        text:'有效',
                        checked:false,
                        group:'zt-group',
                        checkHandler:this.toggleState,
                        scope:this
                    },{
                        text:'有效+预定',
                        checked:false,
                        group:'zt-group',
                        checkHandler:this.toggleState,
                        scope:this
                    },{
                        text:'有效+暂缓',
                        checked:false,
                        group:'zt-group',
                        checkHandler:this.toggleState,
                        scope:this
                    },'-',{
                      text:'预定',
                      checked:false,
                      group:'zt-group',
                      checkHandler:this.toggleState,
                      scope:this
                    },{
                      text:'暂缓',
                      checked:false,
                      group:'zt-group',
                      checkHandler:this.toggleState,
                      scope:this
                    },{
                      text:'已售',
                      checked:false,
                      group:'zt-group',
                      checkHandler:this.toggleState,
                      scope:this
                    },{
                      text:'已租',
                      checked:false,
                      group:'zt-group',
                      checkHandler:this.toggleState,
                      scope:this
                    },{
                      text:'我售',
                      checked:false,
                      group:'zt-group',
                      checkHandler:this.toggleState,
                      scope:this
                    },{
                      text:'我租',
                      checked:false,
                      group:'zt-group',
                      checkHandler:this.toggleState,
                      scope:this
                    },{
                      text:'无效',
                      checked:false,
                      group:'zt-group',
                      checkHandler:this.toggleState,
                      scope:this
                    }]
                }
            },'-', 
            {
                text:'',
                iconCls:'add2',
                split:true,
                handler: function(){
                  add_czxx();
                },
                menu:{
                  id:'czxx-plus-menu',
                  items:[{
                      text:'新增房源',
                      scope:this,
                      iconCls:'add2',
                      handler: function(){
                        add_czxx();
                      }
                  },{
                      text:'修改房源',
                      scope:this,
                      iconCls:'new',
                      handler: function(){
                        add_czxx(this.gsm);
                      }
                  },{
                      text:'删除房源',
                      checked:true,
                      iconCls:'delete',
                      handler: function() {
                        var pars = {id:czxx_id};
                        Ext.Msg.confirm('信息','确定要删除？', function(btn){
                          if (btn == 'yes') {
                            new Ajax.Request("/desktop/delete_czxx", { 
                              method: "POST",
                                parameters: pars,
                                onComplete:  function(request) {
                                  Ext.getCmp('czxx-view').reloadStore();
                                }
                            });                         
                          }
                        });
                      }
                  }]
                }
            },
            new Ext.form.ComboBox({
              mode: 'remote',
              triggerAction: 'all',
              name:'cb_ygxm',
              emptyText:'全部',
              width:60,
            //  store: users_store,
              store : qy_store,
              valueField:'value',
              displayField:'value',
              listeners:{
                scope: this,
                'select': function(combo){
                  this.reloadStore();
                }
              }
            }),
            '->', 
            new Ext.form.TextField({
              width:200,
              enableKeyEvents: true, 
              initEvents: function() { 
                var keyPress = function(e){ 
                  if (e.getKey() == e.ENTER) { 
                    Ext.getCmp('czxx-view').reloadStore();
                  }
                }; 
                this.el.on("keypress", keyPress, this);
              }
            }), 
            {
                text: '查询',
                tooltip:'智能查询',
                iconCls:'search',
                handler:function() {
                  Ext.getCmp('czxx-view').reloadStore();
                }
            },
            new Ext.PagingToolbar({
              store: this.grid.store,
              pageSize: 15,
              displayInfo: true,
              displayMsg: '{0} - {1} of {2}',
              emptyMsg: "没有找到！",
              prependButtons: true
            })    
        ],
        items: [{
            region:"center",
            layout: 'fit',
            items: this.grid
          },
          {
            region:"north",
            height:70,
            split:true,
            //collapsible:true,
            collapsed:true,
            collapseMode:'mini',
            layout: 'absolute',
            id:'czxx_north_search',
            items:[{
                xtype: 'form',
                width: 800,
                height: 70,
                layout: 'absolute',
                border: false,
                items: [
                    {
                        xtype: 'label',
                        text: '交易',
                        x: 10,
                        y: 10
                    },
                    {
                        xtype: 'label',
                        text: '状态',
                        x: 120,
                        y: 10
                    },
                    {
                        xtype: 'label',
                        text: '用途',
                        x: 240,
                        y: 10
                    },
                    {
                        xtype: 'label',
                        text: '价格',
                        x: 360,
                        y: 10
                    },
                    {
                        xtype: 'label',
                        text: '-',
                        x: 452,
                        y: 10
                    },
                    {
                        xtype: 'label',
                        text: '-',
                        x: 452,
                        y: 40,
                        width: 10
                    },
                    {
                        xtype: 'label',
                        text: '类型',
                        x: 240,
                        y: 40
                    },
                    {
                        xtype: 'label',
                        text: '日期',
                        x: 10,
                        y: 40
                    },
                    {
                        xtype: 'label',
                        text: '面积',
                        x: 360,
                        y: 40
                    },
                    {
                        xtype: 'combo',
                        x: 40,
                        y: 10,
                        width: 70,
                        name: 'jy',
                        emptyText:'全部',
                        store: cz_store,
                        mode: 'local',
                        valueField:'text',
                        displayField:'text',
                        triggerAction:'all'
                    },
                    {
                        xtype: 'combo',
                        x: 150,
                        y: 10,
                        width: 70,
                        name: 'zt',
                        emptyText:'全部',
                        store: zt_store,
                        mode: 'local',
                        valueField:'text',
                        displayField:'text',
                        triggerAction:'all'
                    },
                    {
                        xtype: 'combo',
                        x: 270,
                        y: 10,
                        width: 70,
                        name: 'yt',
                        emptyText:'全部',
                        store: yt_store,
                        mode: 'local',
                        valueField:'text',
                        displayField:'text',
                        triggerAction:'all'
            
                    },
                    {
                        xtype: 'textfield',
                        x: 390,
                        y: 10,
                        width: 60,
                        name: 'jg1',
                        value: '0'
                    },
                    {
                        xtype: 'textfield',
                        x: 460,
                        y: 10,
                        width: 60,
                        name: 'jg2',
                        emptyText:'不限'
                    },
                    {
                        xtype: 'datefield',
                        x: 40,
                        y: 40,
                        name: 'date1',
                        width: 90,
                        format: 'Y-m-d',
                        value: (new Date()).format('Y-m-d')
                    },
                    {
                        xtype: 'datefield',
                        x: 130,
                        y: 40,
                        name: 'date2',
                        width: 90,
                        format: 'Y-m-d',
                        value: (new Date()).format('Y-m-d')
                    },
                    {
                        xtype: 'combo',
                        x: 270,
                        y: 40,
                        width: 70,
                        name: 'lx',
                        emptyText:'全部',
                        store: lx_store,
                        mode: 'local',
                        valueField:'text',
                        displayField:'text',
                        triggerAction:'all'
                    },
                    {
                        xtype: 'textfield',
                        x: 390,
                        y: 40,
                        width: 60,
                        name: 'mj1',
                        value: '0'
                    },
                    {
                        xtype: 'textfield',
                        x: 460,
                        y: 40,
                        width: 60,
                        name: 'mj2',
                        emptyText:'不限'
                    },
                    {
                        xtype: 'button',
                        x: 550,
                        y: 10,
                        width : 50,
                        height : 50,
                        text : '查找',
                        handler: function(){
                            Ext.getCmp('czxx-view').reloadStore();
                        }
                    }
                ]
            }]
          },
          {
            region:"south",
            //title:"详细信息",
            height:150,
            split:true,
            //collapsible:true,
            collapseMode:'mini',
            //titleCollapse:true,
            layout:'border',
            items:[
            {
                  id: 'czgj-grid',
                  region:"center",
                  layout: 'absolute',
                  width: 400,
                  items: [czgjGrid, dkgjGrid]
              },
              {
                  region:"west",
                  layout: 'fit',
                  id: "czxx_detailPanel",
                  width:300,
                  bodyStyle: {
                    background: '#ffffff',
                    padding: '7px'
                  }
              },
              {
                  region:"east",
                  //layout:'accordion',
                  id: "speedbuttons",
                  width:50,
                  bodyStyle: {
                    background: '#cccccc',
                    padding: '3px'
                  },
                  items:[
                    new Ext.Button(action1),
                    new Ext.Button(action2),
                    new Ext.Button(action3),
                    new Ext.Button(action4),
                    new Ext.Button(action5)
                  ]                 
            }]
        }]
    });

    this.gsm = this.grid.getSelectionModel();

    this.gsm.on('rowselect', function(sm, index, r){
          czxx_id = r.id;
          var detailPanel = Ext.getCmp('czxx_detailPanel');
          czxxTpl.overwrite(detailPanel.body, r.data);
          
          //reload  czgj
          this.czgjStore.baseParams = {id:czxx_id}
          this.czgjStore.load();
          
          //reload  dkgj
          this.dkgjStore.baseParams = {id:czxx_id}
          this.dkgjStore.load();
              
    }, this, {buffer:250});

    //this.grid.store.on('beforeload', this.czxxform.clear, this.czxxform);

    this.grid.store.on('load', function(){ 
        if (czxx_id==0) 
          Ext.getCmp('czxx-view').gsm.selectFirstRow();
      }, this.gsm);
      
    this.grid.on('rowdblclick', function(sm, index, r){
        add_czxx(Ext.getCmp('czxx-view').gsm);  
    }, this);
    
    if (currentUser.prev_code[11] != 't') {
      Ext.getCmp('czxx-plus-menu').items.items[2].hide();
    };

    if (currentUser.prev_code[12] != 't') {
      Ext.getCmp('czxx-plus-menu').items.items[1].setText('查看房源');
    };
    
    
};

Ext.extend(CzxxPanel, Ext.Panel, {
    loadFeed : function(feed){
      if (feed == 'czxxs') {
        Ext.getCmp('czxx-view').setTitle(feed.text);
      }
    },
    
    reloadStore : function() {
      var btn_0 = Ext.getCmp('czxx-view').getTopToolbar().items.get(0);
      var btn_1 = Ext.getCmp('czxx-view').getTopToolbar().items.get(1);
      var btn_2 = Ext.getCmp('czxx-view').getTopToolbar().items.get(2);
      
      //search Text
      var btn_5 = Ext.getCmp('czxx-view').getTopToolbar().items.get(5);
      var btn_7 = Ext.getCmp('czxx-view').getTopToolbar().items.get(7);
      
      //Advanced Search
      var czxx_ns = Ext.getCmp('czxx_north_search');

      if (czxx_ns.isVisible()) {
        var ns_val = czxx_ns.items.items[0].getForm().getValues();
        paras = {time:btn_0.text, jylx:btn_1.text, zt:btn_2.text, qy:btn_5.getValue() ,search:btn_7.getValue(), start:0, limit:15, date1:ns_val.date1, date2:ns_val.date2, jg1:ns_val.jg1, jg2:ns_val.jg2, mj1:ns_val.mj1, mj2:ns_val.mj2, jy:ns_val.jy, lx:ns_val.lx, yt:ns_val.yt, zt:ns_val.zt} 
      } else {
        paras = {time:btn_0.text, jylx:btn_1.text, zt:btn_2.text, qy:btn_5.getValue() ,search:btn_7.getValue(), start:0, limit:15};
      }
      
      //set seleted czxx_id  to null
      czxx_id = 0;
      this.grid.loadData(paras);
      
      //reald czgj
      this.czgjStore.baseParams = {id:czxx_id}
      this.czgjStore.load();
      
    },
    
    toggleTime : function(m, pressed){
      
        if(!m){ // cycle if not a menu item click
            var items = Ext.menu.MenuMgr.get('czxx-slelect-menu').items.items;
            
            for (var k=0; k < items.size(); k++) {
              if (items[k].checked) {
                if (items[(k+1)%items.size()].itemCls == 'x-menu-sep') k = k+1;
                items[(k+1)%items.size()].setChecked(true);
                break;
              } 
            }
            
            return;
        };
        
        if(pressed){
            //var preview = this.grid;
            var btn = Ext.getCmp('czxx-view').getTopToolbar().items.get(0);
            //btn.setIconClass('add');
            btn.setText(m.text);
            
            switch(m.text){
                case '全部房源':
                    btn.setIconClass('t0');
                    break;              
                case '今日新房':
                    btn.setIconClass('t1');
                    break;
                case '最近三天':
                    btn.setIconClass('t3');
                    break;
                case '最近七天':
                    btn.setIconClass('t7');
                    break;    
            };
            
            //reload store
            this.reloadStore();
        }
        
    },

    toggleType : function(m, pressed){
        if(!m){ // cycle if not a menu item click
            var items = Ext.menu.MenuMgr.get('czxx-option-menu').items.items;
            for (var k=0; k < items.size(); k++) {
              if (items[k].checked) {
                if (items[(k+1)%items.size()].itemCls == 'x-menu-sep') k = k+1;
                items[(k+1)%items.size()].setChecked(true);
                break;
              } 
            }
            return;
        }
        
        if(pressed){
            var btn = Ext.getCmp('czxx-view').getTopToolbar().items.get(1);
            //btn.setIconClass('option');
            btn.setText(m.text);
            
            switch(m.text){
                case '租售':
                    btn.setIconClass('option');
                    break;              
                case '出租':
                    btn.setIconClass('tz');
                    break;
                case '出售':
                    btn.setIconClass('ts');
                    break;
            };
            
            //reload store
            this.reloadStore();
        }
    },

    toggleState : function(m, pressed){
        if(!m){ // cycle if not a menu item click
            var items = Ext.menu.MenuMgr.get('czxx-state-menu').items.items;
            for (var k=0; k < items.size(); k++) {
              if (items[k].checked) {
                if (items[(k+1)%items.size()].itemCls == 'x-menu-sep') k = k+1;
                items[(k+1)%items.size()].setChecked(true);
                break;
              } 
            }
            return;
        }
        
        if(pressed){
            var btn = Ext.getCmp('czxx-view').getTopToolbar().items.get(2);
            //btn.setIconClass('option');
            btn.setText(m.text);
            
            switch(m.text){
                case '租售':
                    btn.setIconClass('option');
                    break;              
                case '出租':
                    btn.setIconClass('tz');
                    break;
                case '出售':
                    btn.setIconClass('ts');
                    break;
            };
            
            //reload store
            this.reloadStore();
            
        }
    }

});

Ext.reg('appczxxpanel', CzxxPanel);